美文网首页
c++ reference to non-static memb

c++ reference to non-static memb

作者: 送分童子笑嘻嘻 | 来源:发表于2020-02-25 10:08 被阅读0次

参考文章
https://blog.csdn.net/qq_26849233/article/details/77930991

之前写多线程函数getData 在main中调用时,
std:thread t(getData)
getData的实现是
void getData(){
}

但是如果是在一个类的构造方法中调用时,这样写就会报错,reference to non-static member function must be called
解决方法是,在类的头文件中将getData设置为静态方法

相关文章

网友评论

      本文标题:c++ reference to non-static memb

      本文链接:https://www.haomeiwen.com/subject/mzxgqhtx.html