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;
}
}
网友评论