我正在上课,我想在一个方法中返回我的课程.我的班级有一个rapidjson::Document对象.
您可以在此处查看以前的问题:LNK2019:使用rapidjson"未解析的外部符号"
正如我所发现的,rapidjson阻止您执行该Document对象的任何类型的副本,然后包含Document对象的类的默认副本失败.我正在尝试定义自己的复制构造函数,但我需要执行该对象的副本.我看到了一种假设用.Accept()方法复制对象的方法,但是在rapidjson::Document类中返回了很多错误:
错误C2248:'无法访问类`rapidjson :: GenericDocument'中声明的私有成员
这是我的复制构造函数:
jsonObj::jsonObj(jsonObj& other)
{
jsonStr = other.jsonStr;
message = other.message;
//doc = other.doc;
doc.Accept(other.doc);
validMsg = other.validMsg;
}
Run Code Online (Sandbox Code Playgroud)
我在图书馆的代码(第52-54行)中找到了" Copy constructor is not permitted".
这是我的班级:
class jsonObj {
string jsonStr;
Document doc;
public:
jsonObj(string json);
jsonObj(jsonObj& other);
string getJsonStr();
};
Run Code Online (Sandbox Code Playgroud)
方法:
jsonObj testOBJ()
{
string json = "{error:null, message:None, errorMessage:MoreNone}";
jsonObj b(json);
return b; //It fails here if …Run Code Online (Sandbox Code Playgroud)