This topic has been archived. It cannot be replied.
-
工作学习 / English / A question about C++ polymorphism & inheritence
-bills(Bill);
2001-7-16
(#133602@0)
-
你都没说是什么问题,如何帮你:-/
-happy_4_7(开心果);
2001-7-16
(#133715@0)
-
Here you are! THANKS.
-bills(Bill);
2001-7-16
{1766}
(#133846@0)
-
the reasons: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.
-redriver(redriver);
2001-7-16
{384}
(#134183@0)
-
You are right, the key point is “if you override one of the overloaded member functions in the base class, the other overloaded versions become hidden in the derived class”
-birdincage(birdincage);
2001-7-17
(#134765@0)
-
So it is C++ specific error, right?I mean, in general OO concept, the derived class should be able to only override one of the
overloaded function in base calss, and not necessory to do anything to make the others visiable in derived class.
Anyway, thanks very much!
-bills(Bill);
2001-7-17
{235}
(#134885@0)
-
No, it is not an error. The real world is complicated. What if the derived class has its own ways for other overloaded functions? There is always a trade-off.
-birdincage(birdincage);
2001-7-17
(#135397@0)
-
Sorry, it is a C++ compiler specific error, right?:)
-bills(Bill);
2001-7-17
{2}
(#134886@0)
-
Thanks guys, but .. come in pls.
-bills(Bill);
2001-7-17
{1322}
(#135074@0)
-
I got an explanation for you.
-oasis(oasis);
2001-7-18
{835}
(#136053@0)