C
Carl Ribbegaardh
I'm sorry if I ask something that's in the FAQ but I've searched google for
hours now. Maybe I'm looking for the wrong terms?
I have written a linked list class which is a template class. I've pretty
much followed the GOF recipe from the Iterator pattern example.
The follwing works fine in eg main:
LinkList<User*> users;
users.Add(new User("John"));
I can also instantiate objects like this from main:
LinkList<User*>* aUser= new LinkList<User*>();
If I try to have a linked list as a member in the User things go bad...
class User{
private:
LinkList<Stuff*>* m_pStuff;
};
and in the constructor:
User::User()
{
m_pStuff = new LinkList<Stuff*>();
}
This gives all sorts of errors which seems to me like the member pointer is
syntactically incorrect. How can I have a member pointer variable pointing
to a template class object?
What's the correct syntax?
Can it be done as an auto_ptr too?
TIA
/Carl
hours now. Maybe I'm looking for the wrong terms?
I have written a linked list class which is a template class. I've pretty
much followed the GOF recipe from the Iterator pattern example.
The follwing works fine in eg main:
LinkList<User*> users;
users.Add(new User("John"));
I can also instantiate objects like this from main:
LinkList<User*>* aUser= new LinkList<User*>();
If I try to have a linked list as a member in the User things go bad...
class User{
private:
LinkList<Stuff*>* m_pStuff;
};
and in the constructor:
User::User()
{
m_pStuff = new LinkList<Stuff*>();
}
This gives all sorts of errors which seems to me like the member pointer is
syntactically incorrect. How can I have a member pointer variable pointing
to a template class object?
What's the correct syntax?
Can it be done as an auto_ptr too?
TIA
/Carl