Can't push_front () standard library list with my objects in C ++
I have a class and I would like to use a standard list of libraries to store a list of them. I really want a push_front () list. So my code looks like this:
#include <list>
/* ... lots of stuff ...*/
complexNode myObject();
std::list<complexNode> complexList();
myList.push_front(myObject);
But the compiler throws this error:
error: request for member 'push_front in' complexList, which is non-class' std :: list <complexNode, std :: allocator <complexNode -> () ()
The complexNode class has a counter-copy.
I don't really understand the problem and what this error actually means ... please help!
a source to share
It:
std::list<complexNode> complexList();
Commonly named " C ++ Most Unpleasant Parsing ". In short, you've made complexList
it a function declaration that returns a list, not a local variable. Remove ()
then it cannot be parsed as a function.
a source to share