#include <iostream>
#include <string>
#include <list>
class OtherClass{
int something;
string somethingelse;
}
class NewClass{
list<OtherClass> List;
public:
NewClass(){ return list<OtherClass> List} //C'tor
}
int main(){ //I do not return any value so 'int main()' is pointless here
NewClass test=NewClass("New"); //C'tor
test.push_front (p1); //p1 is already declared and allocated //ERROR
}
The error I get is:
error C2039: 'push_front' : is not a member of 'NewClass', but this is STL list's method and I have included it. Will be glad to get some help.
1) Constructors don't return anything, they construct the object. I'm not sure you understand how functions work anyway. Go read up some on them.
2) Your class doesn't have a push_front method, so the compiler complains. Just because you have a list in there doesn't mean you can magically expect it to know you mean to push_front in that list.