Search code examples
c++stdlist

Can't push_front() a standard library list with my objects in C++


I have an class and I would like to use the standard library list to store a list of them. I essentially want to push_front() the list. So my code is 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 of non-class type ‘std::list<complexNode, std::allocator<complexNode> > ()()’

The class complexNode has a copy contructor.

I really don't understand the problem and what that error actually means... please help!


Solution

  • std::list<complexNode> complexList();
    

    shouldn't this be :

    std::list<complexNode> complexList; // without the ()