Error: Missing ';' before '*'

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
I see 3 *. The error message must tell which of them is offending.

Object?
I updated the original post to show it more specifically. Yes, it is on the line with Object.
The obvious question is: What is Object? What does the compiler know about identifier "Object" when it enters that fateful line of code?
Well we are making a templated class, so Object can be anything. Otherwise I don't really understand your question...
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
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?
Well we are making a templated class
where is this class declaration for this located?
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
#pragma once
#include <iostream>

using namespace std;

template <class T>

class Book
{
friend ostream& operator<<(ostream &out, const Book<T> &other);

public:
	Book<T>();
   
.......... other functions.............

       ~Book<T>();

private:
    struct Node
    { 
        Object *data;
        Node *next;
    };
    Node* head;
};


This is exactly everything I have in the .h file. I don't have anything else, and I am getting an error with Object.
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
1
2
3
4
5
struct Node
    { 
        T *data;  //instead of Object
        Node *next;
    };

Is this what you're trying to express? It is hard to connect what a Node has to do with a Book with no context.
Topic archived. No new replies allowed.