
C++中关于no matching function for call to的报错
#include<iostream>#include<string>usingnamespacestd;classstudent{protected:intnumber;...
#include <iostream>
#include <string>
using namespace std;
class student
{
protected:
int number;
string name;
float score;
public:
student(int number1,string name1,float score1)
{
number=number1;
name=name1;
score=score1;
}
void print()
{
cout<<"number:"<<number<<endl;
cout<<"name:"<<name<<endl;
cout<<"score:"<<score<<endl;
}
};
class ustudent:public student
{
private:
string major;
student auditor1;
student auditor2;
public:
ustudent(int number1,string name1,float score1,int number2,string name2,float score2,int number3,string name3,float score3,string major1):student(number1,name1,score1),auditor2(number3,name3,score3),auditor1(number2,name2,score2)
{
major=major1;
}
void print()
{
cout<<"正式生是"<<endl;
student::print();
cout<<"major:"<<major<<endl;
}
void print_auditor1()
{
cout<<"旁听生是:"<<endl;
auditor1.print();
}
void print_auditor2()
{
cout<<"旁听生是:"<<endl;
auditor2.print();
}
};
int main ()
{
ustudent b1(211,"张三",2009,111,"李四",8766,112,"王五",6544);
b1.print();
b1.print_auditor1();
b1.print_auditor2();
return 0;
}
报错是 [Error] no matching function for call to 'ustudent::ustudent(int, const char [5], int, int, const char [5], int, int, const char [5], int)'
有大神知道怎么解决吗!求指点! 展开
#include <string>
using namespace std;
class student
{
protected:
int number;
string name;
float score;
public:
student(int number1,string name1,float score1)
{
number=number1;
name=name1;
score=score1;
}
void print()
{
cout<<"number:"<<number<<endl;
cout<<"name:"<<name<<endl;
cout<<"score:"<<score<<endl;
}
};
class ustudent:public student
{
private:
string major;
student auditor1;
student auditor2;
public:
ustudent(int number1,string name1,float score1,int number2,string name2,float score2,int number3,string name3,float score3,string major1):student(number1,name1,score1),auditor2(number3,name3,score3),auditor1(number2,name2,score2)
{
major=major1;
}
void print()
{
cout<<"正式生是"<<endl;
student::print();
cout<<"major:"<<major<<endl;
}
void print_auditor1()
{
cout<<"旁听生是:"<<endl;
auditor1.print();
}
void print_auditor2()
{
cout<<"旁听生是:"<<endl;
auditor2.print();
}
};
int main ()
{
ustudent b1(211,"张三",2009,111,"李四",8766,112,"王五",6544);
b1.print();
b1.print_auditor1();
b1.print_auditor2();
return 0;
}
报错是 [Error] no matching function for call to 'ustudent::ustudent(int, const char [5], int, int, const char [5], int, int, const char [5], int)'
有大神知道怎么解决吗!求指点! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询