请问我这个主函数里该咋写,怎么都不对呢,左后要输出他所有信息。
一直显示这个错误,在Professor p1("teacher",2002,4,3);倒数第四行
[Error] no matching function for call to 'Professor::Professor(const char [8], int, int, int)'
#include
#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<<"出生日期 : "<" 年 "<" 月 "<" 日 "<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<<"工号:"<" 姓名:"<" 性别:"<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<<"职称:"<();
}
};
int main()
{
Teacher t1(4637283,"zhangsan",'m');
t1.showInfo();
Professor p1("teacher",2002,4,3);
p1.display();
return 0;
}
Professor构造函数参数个数不正确,Professor构造函数有7个, 你倒数第四行只传递了4个。