1

Possible Duplicate:
Why shall I use the “using” keyword to access my base class method?

using declaration introduces a name of data member or member function from a base class into the scope of derived class which is implicitly accomplished when we derive a class from base class, then what is the utility of using "using declaration"?

i want to know in depth the use of using declaration in classes in c++.

Community
  • 1
  • 1

1 Answers1

4
struct Base()
{
   void f(char);
};

struct Derived: Base
{
   void f(int);
};

int main()
{
   Derived d;
   d.f('a');
}

Which do you think will be called? It appears that f(int) is called, because the name f hides the name f in Base. So you need a using-declaration to enable it.

struct Derived: Base
{
   using Base::f;
   void f(int);
};

Now f(char) will be called.

That's one example. HTH

Armen Tsirunyan
  • 130,161
  • 59
  • 324
  • 434