Jump to content
  • Advertisement
Sign in to follow this  
enmaniac

C++ problem

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
};

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!