Help in working in Object Oriented so far.

Hello for the past few hours I've been working with object oriented,
Last edited on
1
2
3
std::vector<std::pait<char, bool>> word;
for(char x: words[index])
    word.push_back(std::make_pair(x, false));
You need to turn on C++11 support
Ohh! I had a typo I meant pair

Last edited on
Whoops. Visual studio 2008 is not supporting C++2011
Use this:
1
2
3
4
std::vector<std::pair<char, bool>> word;
const std::string guessWord = words[index];
for(i = 0; i < guessWord.size(); ++i)
    word.push_back(std::make_pair(guessWord[i], false));

And ignore first warning.
Its working but how do i keep track of incorrect guesses of letters,
Create int variable and increase it every time when user guesses incorrectly.
1
2
3
int answer; 
if (answer = false);
answer++;

is that okay?
No. Your construct woll increase answer by 1 regardless of everything.
It should be something like:
1
2
3
4
int fails = 0;//Initialize it!
/*...*/
if(/*answer is not right*/)
    ++fails;
it just shows me a random word when i compile
1
2
3
int fails = 0;
if(!guessWord.size())
    ++fails;
?
Last edited on
Heres the code
[
[/code]
and heres the output
http://i41.tinypic.com/v5ba4m.jpg
Last edited on
word!=guessWord.size() What are you trying to do here?
if its not equal to the randomed word,
if letter is not equal to size of guessWord actually.
And I do not know what do you want to do with that.

Create algorithm first. Then try to follow it. Then if everythig is alright, think how to implement it in C++.
I will finish it by tomorrow, im too sleepy i cant think at all.
THANKS ALOT bro
Last edited on
Topic archived. No new replies allowed.