Problem with vectors

I'm new to vectors so this is probably a stupid mistake.
vector<VideoMode> fulscr= VideoMode::getFullscreenModes();
while (fulscr.size()>7) 
vector<Text> restxt;
for (unsigned i=0; i<fulscr.size(); i++)
{restxt[i]=(fulscr[i].width+"x"+fulscr[i].height, schwab, 18);}

I'm getting
 error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)

Any help would be much appreciated

Edit: I'm using namespace sf & namespace std
Last edited on
What is this line supposed to do? restxt[i]=(fulscr[i].width+"x"+fulscr[i].height, schwab, 18);

Edit:Nevermind, I looked at sf::Text reference and I see you are trying to construct an sf::Text. Try restxt[i]=sf::Text(std::to_string(fulscr[i].width)+"x"+std::to_string(fulscr[i].height), schwab, 18);
Last edited on
Thanks, I'm a lot closer to what I wanted to do, but now it's telling me
error C2668: 'std::to_string' : ambiguous call to overloaded function
First of all this code is invalid

vector<Text> restxt;
for (unsigned i=0; i<fulscr.size(); i++)
{restxt[i]=(fulscr[i].width+"x"+fulscr[i].height, schwab, 18);}

You defined vector restxt as an empty vector

vector<Text> restxt;

so you may not use the subscript operator because there are no such elements in this vector.

As for the last error then it seems that you are using MS VC++ 2010 that contains a bug in the definition of the family of functions std::to_string that is this function is not overloaded for type int. You should cast the argument of the function for one of the types that listed in the error message.
Last edited on
Yeah, I know, forgot to use pushback :3
Thanks, converted the int variables to unsigned long that fixed the error
Topic archived. No new replies allowed.