关于string类型的问题,在构造Employee类时的错误不明白
#include<iostream>#include<cstring>
using namespace std;
class Employee{
public:
Employee(string* Name,string* City,string* Address,string* Postcode){
strcpy(Name,N);
strcpy(Address,A);
strcpy(City,C);
strcpy(Postcode,P);;
~Employee(){};
void display(){};
void chang_name(string* Name,string* City,string* Address,string* Postcode){};
private:
string Name;
string City;
string Address;
char Postcode;
};
void Employee::display(){
cout<<"Name: "<<Name<<" City: "<<City<<" Address: "<< Postcode: "<<endl;
}
void Employee::chang_name(string Name,string City,string Address,string Postcode){
cout<<"Please enter the name:"<<endl;
cin>>Name;
cout<<"Please enter the city:"<<endl;
cin>>City;
cout<<"Please enter the address:"<<endl;
cin>>Address;
cout<<"Please enter the postcode:"<<endl;
}
int main(){
int i;
Employee *people=new Employee[5];
for(i=0;i<6;i++){
cout<<"Please inter the "<<(i+1)<<"'s information"<<endl;
Employee[i].change_name();
}
for(i=;i<6;i++){
cout<<"the result is:"<<endl;
Employee[i].display();
}
return 0;
}
机器在编译时在display()函数处报错,说是newline in constant,这是什么情况??还有,我这样写程序可以么???