当我尝试为MyGraphBuilder Class编写一个Mutator时,我得到以下Errors:错误1:无效使用非静态数据成员'MyGraph']error2:“ MyGraph”是“ MyGraphBuilder”的私有成员mygraphbuilder.h:51:11:注意:在此声明为私有您能帮我解决这个问题吗!
using namespace boost;
using namespace std;
typedef adjacency_list < vecS, vecS, directedS, property < vertex_name_t, idType >, property < edge_weight_t, double > > graph_t;
class MyGraphBuilder
{
private:
graph_t MyGraph;
// Mutator declared in Header, and Defined in The CPP File
void setGraph(graph_t);
//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 , The Rest From Header
}; // end of class
我很确定它应该在cpp文件中像这样格式化
void MyGraphBuilder::setGraph(graph_t YourGraph){
MyGraph = YourGraph;
}