C++ question

RichieZ

Diamond Member
Jun 1, 2000
6,551
40
91
Lets say you have a pointer to a linked list, from doing the following:

list<int> *L1;
L1 = new list<int>();

how do you access the functions provided by the list STL?

When I try and do:
L1.push_back(5);

I get this error:
...\Part1.cpp(15) : error C2228: left of '.push_back' must have class/struct/union type

Any help?


 

Noriaki

Lifer
Jun 3, 2000
13,640
1
71
You could do (*foo).bar() to if you wanted to.
foo->bar() is cleaner especially if you had nested, and stylistically better. ;)