Error: class "SecretWord" has no member "MistakeCheck"

Feb 10, 2012 at 7:39pm
closed account (365X92yv)
Solved.
Last edited on Feb 10, 2012 at 10:49pm
Feb 10, 2012 at 8:35pm
Exit your IDE, restart it and see if that fixes. I copied your code and it compiles with no error.
Feb 10, 2012 at 11:01pm
closed account (zb0S216C)
Again with the post deletion. You're supposed to leave the OP in place so that others can use this thread as a potential solution to their problem.

Wazzak
Feb 10, 2012 at 11:02pm
Help me understand why my compiler is screwing with me.

SecretWord.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <string>
using namespace std;

class SecretWord
{
public:
	SecretWord::SecretWord();
	void InitPrint();
	void SetWord(string);
	void Guess(SecretWord, char);
	void Print();
	void MistakeCheck();
	string word;
	char guess;
private:
	string secretWord;
};



SecretWord.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <string>
using namespace std;

#include "SecretWord.h"

SecretWord::SecretWord()
{
	word = "sup";
	secretWord = "-";
}

void SecretWord::SetWord(string userWord)
{
	secretWord = userWord;
}

void SecretWord::InitPrint()
{
	word = secretWord;
	for(size_t i=0;i<word.length();i++)
	{
		word.at( i ) = '-';
	}
	cout << word << endl;
}

void SecretWord::Print()
{
	for(size_t i=0;i<word.length();i++)
	{
		cout << word.at( i );
	}
	cout << endl;
}

void SecretWord::Guess(SecretWord secret, char guess)
{
	for(int i = 0;i<secretWord.length();i++)
	{
		if(guess == secretWord.at(i))
			word.at( i ) = guess;// If it is at the iTH spot of the word
	}

}

void SecretWord::MistakeCheck()
{
	cout << "Sup" << endl;

}
Feb 10, 2012 at 11:12pm
What was the fix?
Feb 10, 2012 at 11:13pm
Turning it off and on again.
Feb 11, 2012 at 12:26am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class SecretWord
{
public:
	SecretWord::SecretWord(); //error: extra qualification ‘SecretWord::’ on member ‘SecretWord’
	void InitPrint();
	void SetWord(string);
	void Guess(SecretWord, char);
	void Print();
	void MistakeCheck();
	string word;
	char guess;
private:
	string secretWord;
};
Feb 11, 2012 at 3:27am
1
2
#include <iostream>
#include <string> 

appears on both secretword.h and secretword.cpp
include this on only on only one file
OR
use these on both files
1
2
3
4
5
6
7
8
9
#ifndef IOSTREAM
#define IOSTREAM
#include <iostream>
#endif

#ifndef STRING
#define STRING
#include <string>
#endif 

Topic archived. No new replies allowed.