按照谭浩强c++第二版敲的代码,居然显示有错,各位能否看一下,谢谢
程序代码:
#include <iostream> #include <string> using namespace std; class Student { public: protected: int num; string name; char sex; }; class Student1:protected Student { public: void get_value1(); void display1(); private: int age; string addr; }; void get_value1() {a cin>>num>>name>>sex; cin>>age>>addr; } void Student1::dispaly1() { cout<<"name"<<name<<endl; cout<<"num"<<num<<endl; cout<<"sex"<<sex<<endl; cout<<"age"<<age<<endl; cout<<"address"<<addr<<endl; } int main() { Student1 stud1; stud1.get_value1(); stud1.display1(); return 0; }