Disclaimer: both solution are for educational purpose and I would not recommend to use it in any real program. If you need to solve homework with strict requirements, then that maybe ok:
First:
istream& operator>>(istream& is, Employee & e) {
Employee tmp;
tmp.name = new char[1024];
is >> tmp.num >> tmp.rate >> tmp.name;
e = tmp;
return is;
}
Second - more ugly and more "effective" solution:
istream& operator>>(istream& is, Employee & e) {
char buffer[1024];
Employee tmp;
tmp.name = buffer;
is >> tmp.num >> tmp.rate >> tmp.name;
e = tmp;
tmp.name = 0;
return is;
}
Again both solution created under condition "to use existing assignment operator", real code should be different.
Note:
if (name != NULL) delete [] name;
is redundant, write
delete [] name;
instead