c++报错:没有与参数列表匹配的构造函数问题? 20
#include<iostream>usingnamespacestd;classTeacher{private:intnum;stringname;charsex;pu...
#include<iostream>
using namespace std;
class Teacher {
private:
int num;
string name;
char sex;
public:
void teacher(int a,string b,char c)
{
num = a;
name = b;
sex = c;
}
void display()
{
cout << num << name << sex << endl;
}
};
class BrithDate {
private:
int year;
int mouth;
int day;
public:
void brithdate(int a,int b,int c)
{
year = a;
mouth = b;
day = c;
}
void display()
{
cout << year << mouth << day << endl;
}
void change(int a,int b,int c)
{
year = a;
mouth = b;
day = c;
}
};
class Professor :public Teacher {
private:
BrithDate brithday;
public:
void professor(int a, string b, char c, int d, int e, int f)
{
teacher(a, b, c);
brithday.brithdate(d, e, f);
}
void display()
{
brithday.display();
Teacher::display();
}
void changebrith(int a, int b, int c)
{
brithday.change(a, b, c);
}
};
int main()
{
cout << "输入编号,姓名,性别,初始年月日" << endl;
int a;string b; char c; int d; int e; int f;
cin >> a >> b >> c >> d >> e >> f;
Professor prof1(a,b,c,d,e,f);
int a1; int a2; int a3;
cout << "输入修改年月日:" << endl;
cin >> a1 >> a2 >> a3;
prof1.changebrith(a1,a2,a3);
prof1.display();
return 0;
}
在主函数中prof1后面的a那里报错的 展开
using namespace std;
class Teacher {
private:
int num;
string name;
char sex;
public:
void teacher(int a,string b,char c)
{
num = a;
name = b;
sex = c;
}
void display()
{
cout << num << name << sex << endl;
}
};
class BrithDate {
private:
int year;
int mouth;
int day;
public:
void brithdate(int a,int b,int c)
{
year = a;
mouth = b;
day = c;
}
void display()
{
cout << year << mouth << day << endl;
}
void change(int a,int b,int c)
{
year = a;
mouth = b;
day = c;
}
};
class Professor :public Teacher {
private:
BrithDate brithday;
public:
void professor(int a, string b, char c, int d, int e, int f)
{
teacher(a, b, c);
brithday.brithdate(d, e, f);
}
void display()
{
brithday.display();
Teacher::display();
}
void changebrith(int a, int b, int c)
{
brithday.change(a, b, c);
}
};
int main()
{
cout << "输入编号,姓名,性别,初始年月日" << endl;
int a;string b; char c; int d; int e; int f;
cin >> a >> b >> c >> d >> e >> f;
Professor prof1(a,b,c,d,e,f);
int a1; int a2; int a3;
cout << "输入修改年月日:" << endl;
cin >> a1 >> a2 >> a3;
prof1.changebrith(a1,a2,a3);
prof1.display();
return 0;
}
在主函数中prof1后面的a那里报错的 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询