#include
using namespace std;
class CStudent{
public:
stu(char *m_name,int m_age,char *m_class);
char name[64];
int age;
char a_class[64];
};
CStudent::stu(char *m_name,int m_age,char *m_class){
strcpy(name,m_name);
age=m_age;
strcpy(a_class,m_class);
}
void main(int argc, char* argv[]){
CStudent stu("华安",14,"三年二班");
cout<<"name is:"<"age is:"<"a_class is:"<
cpp(16) : error C2078: too many initializers
cpp(16) : error C2440: 'initializing' : cannot convert from 'char [9]' to 'class CStudent'
No constructor could take the source type, or constructor overload resolution was ambiguous
执行 cl.exe 时出错.
Cpp36.obj - 1 error(s), 0 warning(s)
你第五行不是构造函数的格式,也不是成员函数的格式,格式有误。
如果你表达的是构造函数应改成Cstudent()
如果你表达的是成员函数前面应该加一个函数类型
构造函数和类名要同名