typedef struct
{
list<int> lc;
} x;
for( li = x.lc.begin(); li != x.lc.end(); li++ )
{
}
gives the error below:
expected primary-expression before '.' token
Any ideas?
Printable View
typedef struct
{
list<int> lc;
} x;
for( li = x.lc.begin(); li != x.lc.end(); li++ )
{
}
gives the error below:
expected primary-expression before '.' token
Any ideas?
x is a type, not an object. That's what the "typedef" means.
Thanks Graham.
what if I do this?
typedef struct
{
int i;
int j;
int k[4];
} x;
x obj;
list<obj> lc; // STL
how do I put values in my elements and access each element using an iterator? I'm thinking to start,
lc.push_back(???) // for each element?
list<obj>::iterator li;
for( li = lc.begin(); li != lc.end(); li++ )
{
??
}
Code:x obj;
list<x> lc; // STL
now how do I access individual elements?
You seem to have that down already with the for loop and the iterator.....
http://www.cppreference.com/wiki/stl/list/start
Please use code tags.