...
The most effective way to avoid slicing of objects is to ensure, whenever possible, that polymorphic base classes are abstract.
Code Block | ||
---|---|---|
| ||
class Employee { public: Employee(string theName) : name(theName) {}; virtual ~Employee(); string getName() const {return name;} virtual void print() const = 0; private: string name; }; |
...