Polymorphism and type conversion-Collection of common programming errors
I’m confused about an aspect of polymorphism. Please consider the following code:
#include
class CBase {
virtual void dummy() {}
};
class CDerived: public CBase {
public:
int a,b,c,d;
CDerived (): a(1),b(2),c(3),d(4) { }
};
int main () {
CBase* pba = new CDerived;
std::cout