the reasons:

redriver (redriver)
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.
(#134183@0)
2001-7-16 -05:00

回到话题: A question about C++ polymorphism & inheritence

回到论坛: HOME枫下论坛枫下论坛主坛工作学习English

URL:   
http://www.rolia.net/zh/post.php?f=0&p=134183