出现这种错误的原因是什么"invalid use of non-static data member "
what is the reason of getting this kind of Errors "invalid use of non-static data member "
当我为类编写突变器时,我遇到了以下错误:
错误1:无效使用非静态数据成员'MyGraph'error2 :"MyGraph
"是'MyGraphBuilder'的私人成员 mygraphbuilder.h:51:11:注意:在这里声明为私有你能帮我解决这个问题吗!
// Header file
class MyGraphBuilder
{
private:
graph_t MyGraph;
// Mutator declared in Header, and Defined in The CPP File
void setGraph(graph_t);
}; // end of class
在 cpp 文件上定义函数
//This Part only From CPP File not From Header so I added Scope
void setGraph(graph_tYourGraph){
MyGraphBuilder::MyGraph = YourGraph;
}
// End of Part from CPP File
我很确定它应该在 cpp 文件中这样格式化
void MyGraphBuilder::setGraph(graph_t YourGraph){
MyGraph = YourGraph;
}
相关文章:
- 如何处理 c++ 中类实现中的"invalid use of non-static data member"?
- C++ "error: invalid use of void expression"
- 收到错误"invalid use of non-static data member 'stu::n' "
- C++ "Invalid use of 'this' in non-member function" ,
- 继承类时"invalid use of incomplete type ‘class tree_node_t’"
- 出现这种错误的原因是什么"invalid use of non-static data member "
- 模板类和'invalid use of incomplete type'错误
- "invalid use of incomplete type" .解决循环依赖关系
- 为什么我会得到"Invalid use of :: (scope resolution operator)?"
- 如何修复库中的"invalid use of non-static member function" 导入另一个库
- 在C++中传递对象会产生'invalid use of non-static member'错误
- 为什么当我尝试在类中创建数组时"invalid use of non-static data member"我会收到错误?
- 具有重载<<运算符的简单模板类失败,"Invalid use of template-id"
- C++ substr 方法 - "invalid use of ‘this’ in non-member function"
- C++错误:" 'class' does not name a type"和"invalid use of incomplete type ‘struct ...' "
- 访问父类的成员"Invalid use of non-static data member" C++
- "invalid use of non static member function" 这是什么?
- 使用 getline 和层次结构时"invalid use of ‘struct main()"
- C++类模板和嵌套结构。 "Invalid use of non-static data member..."
- 多重继承错误'invalid use of incomplete type'