I have class Employee
class Employee
{
public:
char* Name;
char* Position;
int Age;
Employee (const char *_name, const char *_position, int _age)
{
Name = new char[strlen (_name) + 1];
strcpy(Name, _name);
Position = new char[strlen (_position) + 1];
strcpy(Position, _position);
Age = _age;
};
~Employee ()
{
delete [] Name;
delete [] Position;
};
}
I want to change value of field Position by pointer Employee* p.
int main(void){
Employee first("Josh", "secretary", 33);
Employee *p;
p = &(first);
p->Position = "salesman";
}
Is that posible to change this value in this way? I know it that it could be done by changing char* to string. I suppose that I should use class operator '->' or '=' a then resize char* filed and use strcpy to change value but I have no idea how to start.