-3
努力创造一流的运营商:创建一流运营商
class ggg
{
int a;
int b;
operator std::string ()
{
return "hello";
}
};
int main() {
ggg g ;
std::string s = g;
cout<<s;
}
,并得到了错误:
'ggg::operator std::string' : cannot access private member declared in class 'ggg'
如何解决这个问题呢?