|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Class A has a public method f, and another class B is publicly derived
from A. The derived class B has also the same function but with different arguments. Question: In the scope of class B, is the function f overloaded? (yes/ no) class A { public: int f(int x); } class B: public A { public: int f(int x, float y); } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2008-02-08 04:09:26 -0500, ambarish.mitra@gmail.com said:
> Class A has a public method f, and another class B is publicly derived > from A. The derived class B has also the same function but with > different arguments. > > Question: In the scope of class B, is the function f overloaded? (yes/ > no) > > > class A > { > public: int f(int x); > } > > class B: public A > { > public: int f(int x, float y); > } To see if it is overloaded or not, why not try to write some code to test it? More specifically, try invoking f(1) and f(1,1.) on an B object. -- // kira |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Feb 8, 6:09am, ambarish.mi...@gmail.com wrote:
> Class A has a public method f, and another class B is publicly derived > from A. The derived class B has also the same function but with > different arguments. > > Question: In the scope of class B, is the function f overloaded? (yes/ > no) > > class A > { > public: int f(int x); > > } > > class B: public A > { > public: int f(int x, float y); > > > > }- Hide quoted text - > > - Show quoted text - Hi. In this case it's not an overload because the implementation in B hides the implementation in A. Basically, C++ lookup rules will try to find the symbol in class B. Since it'll find it, class A won't be looked up. Leandro Melo |
|
![]() |
| Outils de la discussion | |
|
|