如果 >> 和 << 运算符正在处理指针,我将如何重载它们?
在标题中:
friend std::istream& operator >>( std::istream& ins, Classname* & e);
friend std::ostream& operator <<( std::ostream& outs, const Classname * e);
在 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;
}