Deriving from CObject and using = operator
-
Hello, how is the = operator to be implemented in a class derived from CObject? I derived two classes with one element inside:
class CA : CObject { int a; void operator = (const CA& src) {}; } class CB : CA { int b; }
The first class overwrites the = operator with an empty function. The following code has a mystic result:CA obA; CB obB; obA.a=1; obA.b=2; obB=obA;
The element b is copied, a not. Why? And what do the = operator in CObject? Why is b copied? Do I have to implement the operator in Class CB too? Many questions no answer! Thanx Markus Dr-Kuulun -
Hello, how is the = operator to be implemented in a class derived from CObject? I derived two classes with one element inside:
class CA : CObject { int a; void operator = (const CA& src) {}; } class CB : CA { int b; }
The first class overwrites the = operator with an empty function. The following code has a mystic result:CA obA; CB obB; obA.a=1; obA.b=2; obB=obA;
The element b is copied, a not. Why? And what do the = operator in CObject? Why is b copied? Do I have to implement the operator in Class CB too? Many questions no answer! Thanx Markus Dr-Kuulun -
Hello, how is the = operator to be implemented in a class derived from CObject? I derived two classes with one element inside:
class CA : CObject { int a; void operator = (const CA& src) {}; } class CB : CA { int b; }
The first class overwrites the = operator with an empty function. The following code has a mystic result:CA obA; CB obB; obA.a=1; obA.b=2; obB=obA;
The element b is copied, a not. Why? And what do the = operator in CObject? Why is b copied? Do I have to implement the operator in Class CB too? Many questions no answer! Thanx Markus Dr-KuulunHow does that even compile?
obA.b
doesn't make sense.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
How does that even compile?
obA.b
doesn't make sense.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ