Hi, In C++ what does the error mean "class does not name a type"?
Hi, In C++ what does the error mean "class does not name a type"?
It's syntax error, caused by the parser getting confused by an error in your code.
C++ has a complicated syntax and is very hard to parse correctly, so seemingly innocuous errors like forgetting a ; at the end of a class definition can confuse a compiler to the point where none of the error messages seem to make any sense.
As a rule of thumb, always tackle the first error message first, because all the others could stem from the parser getting confused through the first error.
Errors like the one you asked about are usually triggered by some error above the point the compiler hints at. If there seems to be no code above that error, the error is often triggered by an error in one of the headers you include. try to include them into an empty implementation file and see if they compile Ok.
If all else fails, try to condense the problem own to 20 lines of code which reproduce it. Start by commenting out code until the error goes away. While doing so, you'll most likely find the problem. If not, those 20 lines are perfect for posting them here and ask about the problem.
As I have said most probably you try to use a type before declaration. The code will make things much clear, but I guess you have a code like this :
class someclass
{
public:
......
otherclass other_object;
......
>
};
class otherclass
{
public:
......
someclass some_object;
......
};
Google turns up this link
http://www.codeguru.com/forum/showthread.php?t=422634
Maybe your problem is similar. Can you show some code?
Probably you've left out a type declaration, like in the following:
int main() {
register a a;
}
However, I think the exact error message "class does not name a type" is impossible to provoke.