如果他们正在处理指针,我将如何重载>>和<<运算符?
在标题中:
friend std::istream& operator >>( std::istream& ins, Classname* & e);
friend std::ostream& operator <<( std::ostream& outs, const Classname * e);
Run Code Online (Sandbox Code Playgroud)
在cpp:
std::ostream& operator <<( std::ostream& outs, const Classname * e)
{ // what do I do here?
return outs;
}
std::istream& operator >>( std::istream& ins, Classname* & e){
// what do I do here?
return ins;
}
Run Code Online (Sandbox Code Playgroud)