Hi everybody. I was wondering if you guys could help me.
Here are my .h:
Class Doctor {
const string name;
public:
Doctor();
Doctor(string name);
Doctor & Doctor::operator=(const Doctor &doc);
}
and my main:
int main(){
Doctor d1 = Doctor("peter");
Doctor d2 = Doctor();
d2 = d1;
}
I want to do the operator= function. Can anyone help me? Notice the const member on Doctor.
********EDIT:***** My main problem is that I want another class to have an attribute which is a Doctor like a Pacient has a Doctor. But I want to be able to change my Doctor. Like i am seeing doctor A but I want to see Doctor B. That would be done using a setDoctor function in my other class (Pacient). If it was me doing the code I would say something like this:
class Patient{
Doctor &d;
};
and then change the pointer. However I am using a base code made by one of the teachers and it has the class defined like:
class Patient{
Doctor d;
}
But I think this is impossible to do because with a setDoctor() in the Patient class I would either make a copy or alter the varable itself. The first doesn't make any difference and the second is impossible due to the const. Am I right?