Polymorphism vs DownCasting
问题 Let's say I have a Base class Employee and an derived class Manager , like below: class Employee { public: string Name; }; class Manager : public Employee { public: string Designation; }; While implementing some function like below: Employee* SomeFunction(bool SomeCondition) { Employee *Emp = NULL; if (SomeCondition) { //Code goes here : Both Implementation 1 and 2 work fine! } return Emp; } When SomeCondition is true, I want to return a non-null object of type Manager . In such a scenario,