I get the compile error
cannot call member function ‘bool GMLwriter::write(const char*, MyList<User*>&, std::vector<std::basic_string<char> >)’ without object
when I try to compile
class GMLwriter{
public:
bool write(const char *fn, MyList<User*>& my_vec, vector<string>edges);
};
the function is defined later and called in main with
GMLwriter::write(argv[3], Users, edges);
Users is declared before with MyList<User*> Users; (MyList is a List ADT and I have a User class) and edges is declared with vector<string>edges
to what object is this error referring?
GMLwriter::writeis not static function of GMLwriter, you need to call it through object. For example:If
GMLwriter::writedoesn’t depend on any GMLwriter state(access any member ofGMLwriter), you can make it a static member function. Then you could call it directly without object:then you could call: