This is about base and derived class objects and pointers. I am wondering if line 5 and 6 in the following code are legal? if your answer is that only line 5 is illegal, can you please explain why line 6 is not?
// d is derived class of class b
b baseObj; // Line 1
d derivedObj; // Line 2
b * pbase; // Line 3
d* pderived; // Line 4
derivedObj = baseObj; //line 5
*pderived = *pbase; //line 6
Lines 5 and 6 are illegal unless:
1) 'b' is implicitly convertible to 'd' (has a cast operator), or
2) 'd' contains assignment operator which takes 'b' (value or reference) as an argument.