我想要一个成员变量,它是一个双指针。双指针指向的对象不得从类外部修改。
我的以下尝试产生 “从 'std::string**' 到 'const std::string**' 的无效转换”
class C{
public:
const std::string **getPrivate(){
return myPrivate;
}
private:
std::string **myPrivate;
};
- 如果我只使用一个简单的指针,为什么相同的构造有效
std::string *myPrivate
我该怎么做才能返回只读双指针?
做一个明确的演员是好的风格
return (const std::string**) myPrivate
吗?