请帮我看看为啥赋不了值
程序代码:
#include<iostream> #include<string> using namespace std; class Employee { public: Employee(string nam,string n):name(nam),num(n) { grade=1; wage=0; } protected: string name; string num; int grade; double wage; }; class Technician:virtual public Employee { private: int hour; public: Technician(string nam,string n,int h):Employee(nam,n) { hour = h; grade = 3; wage =100*h; } void show_T(); void get_T(); }; void Technician::show_T() { cout<<"name:"<<name<<endl; cout<<"num:"<<num<<endl; cout<<"grade:"<<grade<<endl; cout<<"wage:"<<wage<<endl; } void Technician::get_T() { cin>>hour; } int main() { Technician t("t","2",100); t.get_T(); //我在这里对hour赋值为4,但为啥不起作用 t.show_T(); return 0; }
对hour赋值后不起作用,请各位指点下