小弟编写了下面代码,在类中想把构造函数放在类的外面定义
但是报错(49) : error C2512: 'Employee' : no appropriate default constructor available
请求援助~~
#include <iostream.h>
#include <string.h>
class Employee
{
public:
Employee(char*,char*,char*,char*,char*);
void ChangeName();
void Display();
protected:
char name[10];
char adress[20];
char city[20];
char province[20];
char postcode[10];
};
Employee::Employee(char NAME[]="UFO",char ADRESS[]="JLU",char CITY[]="CHANG CHUN",char PROVINCE[]="JI LIN",char POSTCODE[]="130000")
{
cout<<"Constructing :\n";
strcpy(name,NAME);
strcpy(adress,ADRESS);
strcpy(city,CITY);
strcpy(postcode,POSTCODE);
strcpy(province,PROVINCE);
}
void Employee::ChangeName()
{
char rename[10];
cin>>rename;
strcpy(name,rename);
name[sizeof(name)-1]='\0';
cout<<"cout name in ChangeName : "<<name<<endl;
}
void Employee::Display()
{
cout<<"Display members in function \"Display\" :"<<endl
<<"name\t\t: "<<name<<endl
<<"adress\t\t:"<<adress<<endl
<<"city\t\t:"<<city<<endl
<<"province\t:"<<province<<endl
<<"postcode\t:"<<postcode<<endl;
}
int main()
{
Employee new_1;
Employee new_2("Rangoon","He Gang");
new_1.Display();
new_2.Display();
return 0;
}