Skip to main content
GameDev.net gamedev.net
🔒 Locked

C++ problem

Started by enmaniac Aug 18, 2005 at 9:31 AM 1 replies 650+ views
Original Post
enmaniac
enmaniac
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
SiCrane
SiCrane
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;};

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.