c++小程序,有一个错误。求高人指点
#include<iostream>#include<string>
using namespace std;
class Student
{
public:
Student(int ,string,float);
void display();
private:
int num;
string name;
float score;
};
Student::Student(int n,string nam,float s)
{
num=n;
name=nam;
score=s;
}
void Student::display()
{
cout<<num<<name<<score<<endl;
}
class Graduate:public Student
{
Graduate (int ,string ,float ,float);
void display();
private:
float pay;
};
Graduate::Graduate(int n,string nam,float s,float p):Student(n,nam,s),pay(p){}
void Graduate::display()
{Student::display();
cout<<pay<<endl;
}
int main()
{
Student stud1(1001,"liuanglong",3.3);
Graduate grad1(2001,"dsddfkjjdfhgkjdf",33.3,33.333);
Student *p=&stud1;
p->display();
p=&grad1;
p->display();
}