i have an inheritance struct A : public B
, i want to hide individual functions from B, is this possible?
i know the opposite is possible using using BMethod
in the A declaration.
cheers
i have an inheritance struct A : public B
, i want to hide individual functions from B, is this possible?
i know the opposite is possible using using BMethod
in the A declaration.
cheers
Can't alter the visibility of the original method.
You could create a method in struct
A
with the same name and have that method be private, but that doesn't prevent the method from being called when an instance of structA
is being referenced by a variable of typeB
.If you want to selectively hide functions from B it does not make much sense to use public inheritance in the first place.
Use private inheritance & selectively bring methods from B into the scope of A:
There is yet another approach.
Use BInterface as a filter for inherited classes to exclude undesirable methods. Liskov Substitution principle isn't violated in this case since an object of BInterface class is not an object of A class even though that an object of B class is an object of BInterface class.
Why don't you make it Virtual in the base class and override it in its Children? (more help)