-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'
如何解決這個問題呢?