so im making this struct and i want to include a list in it :
1 2 3 4
|
struct student{
int id;
list<classes> clist;
};
|
well it tells me that the clist dusnt exist aka no member named clist
when ever i try to call a function of the list
heres a better test program that gives me the error (so you can see what i mean)
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
|
#include <iostream>
#include <string>
#include <list>
using namespace std;
struct employee{
int num;
string name;
list<int> x;
};
int main()
{
list<employee> test;
employee one;
one.name = "jet";
one.num = 45;
(one.x).push_front(199);
test.push_front(one);
cout << (test.x).front() << endl;
system("pause");
return 0;
}
|
Last edited on
@ writeonsharma
(one.x).push_front(199);
is the same as one.x.push_front(199);
The problem is at line 20:
cout << (test.x).front() << endl; //Error in dereferencing test list
it should be cout << test.front().x.front() << endl;
I'll leave it to CrimsonAngel to see if he can figure out why.
ah i see because its a list of a list xD
thanks lol
it might be same, but these were my view where the error can be.. :)