C++ problem

Started by
1 comment, last by enmaniac 18 years, 8 months ago
Hi! I've got two classes:
class A
{
  public:

    void x( void ){ };
};

class B : public A
{
public:

  void x( int a, int b ){};
};

void main( void )
{
  B b;

  b.x(); // error function does not take 0 params
}
How it is possible that B cannot see method of A ? Thx
Advertisement
What you are experiencing is called hiding. If you create a function in a derived class with the same name as a function in a base class with a different function signature, the function in the derived class hides the function in the base class. You can get around this by changing the name of the function in the derived class or putting a using statement in the derived class.

ex:
class B : public A{public:  void x( int a, int b ){};  using A::x;};
Thx for the fast answer :-)

This topic is closed to new replies.

Advertisement