Advertisement Jump to content
Sign in to follow this  
enmaniac

C++ problem

This topic is 4901 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!