jsoncpp开源代码中的=重载有关问题
jsoncpp开源代码中的=重载问题
jsoncpp是json的C++实现库。里面可以这样的使用:
Json::Value name;
name = "hello";
问题是:如果Value重载=号,且实现了std::string或者char *的形参编译可以通过。
但是代码中实现的却是
Value &operator=( const Value &other );
请教这个问题有人知道吗?
------解决方案--------------------
楼主注意区分JSON ,不要以C++的理念去理解JS
http://www.json.org/json-zh.html
------解决方案--------------------
有两种可能
1.string或char*可以转换为Value
因此
2. Value的operator=支持std::string/char*
------解决方案--------------------
LZ有列出所有的operator=的重载么?
jsoncpp是json的C++实现库。里面可以这样的使用:
Json::Value name;
name = "hello";
问题是:如果Value重载=号,且实现了std::string或者char *的形参编译可以通过。
但是代码中实现的却是
Value &operator=( const Value &other );
请教这个问题有人知道吗?
------解决方案--------------------
楼主注意区分JSON ,不要以C++的理念去理解JS
http://www.json.org/json-zh.html
------解决方案--------------------
有两种可能
1.string或char*可以转换为Value
Value(std::string const& v);
//or
Value(char const*);
因此
value = "hello";
/*
等价于
Value temp = "hello";
value = temp;
*/
2. Value的operator=支持std::string/char*
------解决方案--------------------
LZ有列出所有的operator=的重载么?