error C2248: 'MyString::pCharArray' : cannot access private member declared in class 'MyString'

it2022-05-05  115

std::ostream & operator<<(std::ostream os,const MyString & mystr) { os<<mystr.pCharArray; return os; }; 编译出错; error C2248: 'MyString::pCharArray' : cannot access private member declared in class 'MyString' 修改: std::ostream & operator<<(std::ostream & os,const MyString & mystr) { os<<mystr.pCharArray; return os; }; OK! I've been bitten on the bum by this numerous times; the definition of your operator overload doesn't quite match the declaration, so it is thought to be a different function. The signatures don't match. Your non-member function takes fun& fun, the friend declared on takes const fun& fun.

转载于:https://www.cnblogs.com/hongjiumu/p/3550817.html


最新回复(0)