继承问题,为什么这个程序运行不了?提示没有合适的默认构造函数可用
#include <iostream>#include <string>
using namespace std;
class Student
{
public:
Student(int n, string nam )
{
num=n;
name=nam;
}
void display( )
{
cout<<"num:"<<num<<endl<<"name:"<<name;
}
protected:
int num;
string name;
};
class Student1: public Student
{
public:
Student1(int n1, string nam1,int a):Student(n1,nam1)
{
age=a;
}
void show( )
{
cout<<"This student is:"<<endl;
display();
cout<<"age: "<<age<<endl;
}
private:
Student monitor;
int age;
};
int main( )
{
Student1 stud1(20120107, "Johnson", 20);
stud1.show( );
return 0;
}