我收到编译错误
cannot call member function ‘bool GMLwriter::write(const char*, MyList<User*>&, std::vector<std::basic_string<char> >)’ without object
当我尝试编译
 class GMLwriter{
    public:
    bool write(const char *fn, MyList<User*>& my_vec, vector<string>edges);
};
功能被后面定义和被叫main用
GMLwriter::write(argv[3], Users, edges);
之前声明了用户MyList<User*> Users;(MyList是List ADT,我有一个User类),并且声明了edgevector<string>edges
什么object是这个错误指?
bil*_*llz 18
GMLwriter::write不是GMLwriter的静态函数,需要通过对象调用它.例如:
GMLwriter gml_writer;   
gml_writer.write(argv[3], Users, edges);
如果GMLwriter::write不依赖于任何GMLwriter状态(访问任何成员GMLwriter),则可以使其成为静态成员函数.然后你可以直接调用它而不需要对象:
class GMLwriter
{
public:
   static bool write(const char *fn, MyList<User*>& my_vec, vector<string>edges);
   ^^^^
};
然后你可以打电话:
GMLwriter::write(argv[3], Users, edges);