Oct 29, 2014 at 12:43pm Oct 29, 2014 at 12:43pm UTC
Here is my code:
class Book
{
public:
... (Nothing in here is missing a semicolon or has any errors)
private:
struct Node
{
Object *data; <--- Error for this line " error C2143: syntax error : missing ';' before '*'"
Node *next;
};
Node *head;
};
We were instructed to put the struct Node into the private area. However, the error is telling me that I need a semicolon before the * on data. I don't understand this error. And, the code for the struct was provided for this program so I'm confused on how it is wrong.
Last edited on Oct 29, 2014 at 12:49pm Oct 29, 2014 at 12:49pm UTC
Oct 29, 2014 at 12:47pm Oct 29, 2014 at 12:47pm UTC
I see 3 *. The error message must tell which of them is offending.
Object?
Oct 29, 2014 at 12:49pm Oct 29, 2014 at 12:49pm UTC
I updated the original post to show it more specifically. Yes, it is on the line with Object.
Oct 29, 2014 at 1:05pm Oct 29, 2014 at 1:05pm UTC
The obvious question is: What is Object? What does the compiler know about identifier "Object" when it enters that fateful line of code?
Oct 29, 2014 at 1:10pm Oct 29, 2014 at 1:10pm UTC
Well we are making a templated class, so Object can be anything. Otherwise I don't really understand your question...
Oct 29, 2014 at 1:23pm Oct 29, 2014 at 1:23pm UTC
My compiler complains that identifier "Object" is not defined. . .are you missing a typedef?
PS: make your questions easier to check out by putting code tags around your code. . .
Last edited on Oct 29, 2014 at 1:25pm Oct 29, 2014 at 1:25pm UTC
Oct 29, 2014 at 1:28pm Oct 29, 2014 at 1:28pm UTC
I don't have any typedefs in my code.
Is there something, like a #include or something else I need to be able to use Objects in my code?
Oct 29, 2014 at 1:40pm Oct 29, 2014 at 1:40pm UTC
Well we are making a templated class
where is this class declaration for this located?
Oct 29, 2014 at 2:25pm Oct 29, 2014 at 2:25pm UTC
I don't understand how to define Object. I was just given this code to start with, but how do I start with defining Object?
Last edited on Oct 29, 2014 at 2:33pm Oct 29, 2014 at 2:33pm UTC