请问我这个主函数里该咋写,怎么都不对呢,左后要输出他所有信息。
一直显示这个错误,在Professor p1("teacher",2002,4,3);倒数第四行
[Error] no matching function for call to 'Professor::Professor(const char [8], int, int, int)'
#include <iostream>
#include <string>
using namespace std;
class Date
{
private:
int year;
int month;
int day;
public:
Date(int Y,int M,int D)
{
year=Y;
month=M;
day=D;
}
void show()
{
cout<<"出生日期 : "<<year<<" 年 "<<month<<" 月 "<<day<<" 日 "<<endl;
}
};
class Teacher
{
private:
int num;
string name;
char sex;
public:
Teacher(){}
Teacher(int num2,string na,char s)
{
num=num2;
name=na;
sex=s;
}
void showInfo()//输出
{
cout<<"工号:"<<num<<" 姓名:"<<name<<" 性别:"<<sex<<endl;
}
};
class Professor:public Teacher
{
private:
string title;
Date birthday;
public:
Professor(int num2,string na,char s,string tit,int Y,int M,int D):Teacher(num2,na,s)
,title(tit),birthday(Y,M,D){}
void display()
{
cout<<"职称:"<<title<<endl;
birthday.show();
}
};
int main()
{
Teacher t1(4637283,"zhangsan",'m');
t1.showInfo();
Professor p1("teacher",2002,4,3);
p1.display();
return 0;
}