I'm just about ready to pull my hair out of my head. This should be a simple concept, but it is proving to confound me in every which manner. All I want to do is to assign the value of one object to the values of another object, i.e.
CDog Fido;
CDog Spot;
Fido = Spot;
This is simple enough, and works unless you derive your object from something else. In this case I derived my object from CObject, so it's Declaration looks something like this:
Class CDog : public CObject
{
DECLARE_SERIAL (CDog)
public:
constructor
destructor
copy constructor
yada, yada, yada
private:
int age;
int weight;
CString name;
};
Since I have derived the CDog object from CObject, the compiler doesn't recognize the '=' operator function and I have to make my own. No problem, I'll just overload it and make my own. Problem is, I'm having big troubles doing it. What I'm asking is for someone to help me with some code on overloading the '=' operator and maybe help me out with the copy constructor as well. I've traced my problems to those two areas. Any help on this matter would be HUGELY appriciated.
Thanks,
Nyjil
CDog Fido;
CDog Spot;
Fido = Spot;
This is simple enough, and works unless you derive your object from something else. In this case I derived my object from CObject, so it's Declaration looks something like this:
Class CDog : public CObject
{
DECLARE_SERIAL (CDog)
public:
constructor
destructor
copy constructor
yada, yada, yada
private:
int age;
int weight;
CString name;
};
Since I have derived the CDog object from CObject, the compiler doesn't recognize the '=' operator function and I have to make my own. No problem, I'll just overload it and make my own. Problem is, I'm having big troubles doing it. What I'm asking is for someone to help me with some code on overloading the '=' operator and maybe help me out with the copy constructor as well. I've traced my problems to those two areas. Any help on this matter would be HUGELY appriciated.
Thanks,
Nyjil