1. In the definition of
14 class DETRIVED: public BASE
15 {
16 public:
17 DETRIVED() {};
18 ~DETRIVED() {};
19 fun() { cout << " DETRIVED fun()" << endl; } ;
firstly, the fun() is overided, so the fun(int) in BASE is not accessible in DETRIVED.
secondly, you use "25 DETRIVED *d1= new DETRIVED()", so d1 is pointer of object of DERIVED instead of BASE like d2.
14 class DETRIVED: public BASE
15 {
16 public:
17 DETRIVED() {};
18 ~DETRIVED() {};
19 fun() { cout << " DETRIVED fun()" << endl; } ;
firstly, the fun() is overided, so the fun(int) in BASE is not accessible in DETRIVED.
secondly, you use "25 DETRIVED *d1= new DETRIVED()", so d1 is pointer of object of DERIVED instead of BASE like d2.