1. #include <iostream>
    2. using namespace std;
    3. class Person{
    4. public:
    5. void speak(){
    6. cout << "人在说话" << endl;
    7. }
    8. };
    9. class Student:public Person{
    10. public:
    11. void speak(){
    12. cout << "学生在说话" << endl;
    13. }
    14. };
    15. int main(){
    16. Student student;
    17. student.speak();
    18. return 0;
    19. }

    image.png