I have a base class with a bunch of functionality and a derived class that extends this class, but there are several methods in the base class that don't make sense in the derived class.
Is there anything you can do to prevent these methods from being used by the derived class?
Class A
{
...
public:
void SharedMethod();
virtual void OnlyMakesSenseOnA();
}
Class B : public Class A
{
...
public:
void OnlyMakesSenseOnB();
}
Obviously, the following does not work, but is it possible to do something like this so that the compiler does not allow calling the base class method?
Class B : public Class A
{
...
public:
void OnlyMakesSenseOnA() = 0;
}
source
share