class Adult : public Resident { protected: string education; // 声明一个私有变量 education,表示最高教育水平 string occupation; // 声明一个私有变量 occupation,表示职业

public: void input() { // 定义一个成员函数 input() Resident::input(); // 调用基类 Resident 的 input() 函数 cout << "Enter highest education: "; // 打印提示信息 cin >> education; // 接收用户输入的最高教育水平 cout << "Enter occupation: "; // 打印提示信息 cin >> occupation; // 接收用户输入的职业 }

void output() { // 定义一个成员函数 output()
    Resident::output(); // 调用基类 Resident 的 output() 函数
    cout << "Highest education: " << education << endl; // 打印最高教育水平
    cout << "Occupation: " << occupation << endl; // 打印职业
}

}

标签: 科技


原文地址: https://cveoy.top/t/topic/iwI2 著作权归作者所有。请勿转载和采集!