为什么employee的构造函数的形参要const char*,为什么不能是char*
#include <iostream>
using namespace std;
class employee
{
private:
string name;
string city;
string address;
string id;
public:
void display();
employee(const char* n, const char* c,const char * a, const char* i);
void changename(string* c);
};
void employee::display() {
cout << name << " " << city << endl;
cout << address << " " << id << endl;
}
void employee::changename(string* c)
{
name = *c;
}
employee::employee(const char* n, const char* c, const char* a, const char* i)
{
name = *n;
city = *c;
address = *a;
id = *i;
cout << "创建了一个employee" << endl;
};
int main()
{
employee p1("guy","guyg","huihy","hu");
return 0;
}