class Parent{
char * name;
public:
ostream &operator<<(ostream &os, const Parent&parent) {
os << "name: " << parent.name;
return os;
}
}
class Child:public Parent{
private:
char* childName;
public:
ostream &operator<<(ostream &os, const Child &child) {
os << static_cast<const Parent&>(child) << " childName: " << childName;
return os;
}
}
cpp操作符重载
最新推荐文章于 2022-12-18 23:26:57 发布