The following code does not compile.

The following code does not compile.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
template <class T>
struct node
{
    T it;
    node *next;
};

template <class t>
class act
{
    node next;

};



int main()
{
    return 0;

}


I get the error:
error: 'node' does not name a type.
But, yes it does.
The following code does compile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct node
{
    node *next;
};

template <class t>
class act
{
    node next;

};



int main()
{
    return 0;

}


Am I not allowed to use templates anymore?
Sure you can :)

1
2
3
4
5
6
7
8
9
10
11
12
template <class T>
struct node
{
    T it;
    node<T> *next;
};

template <class t>
class act
{
    node<T> next;
};
heheh thanks, just thought of that too.

Topic archived. No new replies allowed.