条款19: 分清成员函数,非成员函数和友元函数
成员函数和非成员函数最大的区别在于成员函数可以是虚拟的而非成员函数不行。
operator>>或operator<<,为非成员函数。
如果f还需要访问c的非公有成员,让f成为c的友元函数。
istream& operator>>(istream& input, string& string){
delete [] string.data;
read from input into some memory, and make string.data
point to it
return input;
}
ostream& operator<<(ostream& output,const string& string){
return output << string.data;
}