C++显示error C2664:,求解决
#include"stdafx.h"#include"stdio.h"#include<iostream>#include<string>usingnamespacest...
#include "stdafx.h"
#include "stdio.h"
#include <iostream>
#include <string>
using namespace std;
class STU
{
private:
int STU_number;
int STU_age;
char *STU_name;
char *STU_sex;
public:
STU();
STU(int a,int b,char *c,char *d);
STU(const STU &s);
void GetStuData();
protected:
};
STU::STU(const STU &s)
{
STU_number=s.STU_number;
STU_age=s.STU_age;
STU_name=s.STU_name;
STU_sex=s.STU_sex;
}
STU::STU(int a,int b,char *c,char *d)
{
STU_number=a;
STU_age=b;
STU_name=c;
STU_sex=d;
};
void STU::GetStuData()
{
cout<<"名字"<<STU_name<<endl;
cout<<"学号"<<STU_number<<endl;
cout<<"年龄"<<STU_age<<endl;
cout<<"性别"<<STU_sex<<endl;
}
int main(int argc, char* argv[])
{
STU s(3,22,'wzy','man');
s.GetStuData();
return 0;
}
error C2664: '__thiscall STU::STU(int,int,char *,char *)' : cannot convert parameter 3 from 'const int' to 'char *' 展开
#include "stdio.h"
#include <iostream>
#include <string>
using namespace std;
class STU
{
private:
int STU_number;
int STU_age;
char *STU_name;
char *STU_sex;
public:
STU();
STU(int a,int b,char *c,char *d);
STU(const STU &s);
void GetStuData();
protected:
};
STU::STU(const STU &s)
{
STU_number=s.STU_number;
STU_age=s.STU_age;
STU_name=s.STU_name;
STU_sex=s.STU_sex;
}
STU::STU(int a,int b,char *c,char *d)
{
STU_number=a;
STU_age=b;
STU_name=c;
STU_sex=d;
};
void STU::GetStuData()
{
cout<<"名字"<<STU_name<<endl;
cout<<"学号"<<STU_number<<endl;
cout<<"年龄"<<STU_age<<endl;
cout<<"性别"<<STU_sex<<endl;
}
int main(int argc, char* argv[])
{
STU s(3,22,'wzy','man');
s.GetStuData();
return 0;
}
error C2664: '__thiscall STU::STU(int,int,char *,char *)' : cannot convert parameter 3 from 'const int' to 'char *' 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询