Bloomberg LP Interview Question
Software Engineer / DevelopersI don't think so. The pointer P is initialized to point to c ,which is the pointer of an child object instead of the object itself. That means it should be
Parant *p = *c;
or
Parant *p;
p = c;
Correct me if I'm wrong.
=======================
(1) Parent *p=c;
=======================
(2) Parent *p; p=c;
=======================
(1) is same as (2)
I don't see anything wrong with the code.
- Anonymous January 26, 2009Assigning a derived class object to a base class object is legal.