error C2661: 'Student::Student' : no overloaded function takes 3 parameters

#include<iostream>
#include<string>
using namespace std;
class Student
{public:
student(int n,string nam, char s)
{
num=n;
name=nam;
sex=s;
cout <<"Constructor called."<<endl;
}
~Student()
{cout<<"Destructor called."<<endl;}
void display()
{
cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl<<endl;
}
private:
int num;
string name;
char sex;
};
int main()
{
Student stud1(10010,"wang_li",'f');
stud1.display();
Student stud2(10011,"zhang_fun",'m');
stud2.display();
return 0;
}

构造函数是要跟类名同名的,你的类名Student,而构造函数是student,把那个s改大写就行了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-10-12
Vs 2008编译没有错误~~

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网