This happens because the Derived class's member *hides* the base class's
member.
Irrespective of the number/type of parameters.
The solution to solve this problem is to either add an using declaration in
the derived class.
e.g. *using A::f;*
this will bring f(int) of class A within the scope of class B, and thus
allowing the overload to work
or you need to use the scope resolution operator to explicitly call class
A's hidden function.
e.g. *b.A::f(4);*

Hope this helps.


Regards,
Sandeep Jain
Member of Technical Staff, Adobe Systems, India




On Mon, Jul 4, 2011 at 12:42 PM, himanshu kansal <
himanshukansal...@gmail.com> wrote:

> class  A
> {       public:
>        void g(int i)
>        {       cout<<"in a";
>        }
> };
> class B:public A
> {       public:
>        void f()
>        {       cout<<"in b";
>        }
> };
> int main()
> {       B b;
>        b.f();   //vl call b::f()
>        b.g(4);  //vl call a::g()
> }
>
> but
> class  A
> {       public:
>        void f(int i)
>        {       cout<<"in a";
>        }
> };
> class B:public A
> {       public:
>        void f()
>        {       cout<<"in b";
>        }
> };
> int main()
> {       B b;
>        b.f();   //vl call b::f()
>        b.f(4);  //bt here errror occurs not a matching protoype...
> }
>
> my ques is that cant we overload function in inheritance(which vary in
> parameters)..???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to