I’m just wondering if it is possible..
I have a base class, with a variable called Level. I then derive a class from it, but here Level should be called Points.
Is there any way to rename the Level variable in the derived class?
Edit – Excuse me for calling a property a variable. I’m quite new to programming, and especially to classes (Which our teacher doesn’t teach us for some reason)
The closest you could get with inheritance would be:
But that doesn’t actually expose BaseClass.Level, since a protected property is only visible to subclasses.
As @Jason explains, a subclass can’t obscure the public interface of its base class. If you really wanted to do that, you could encapsulate the base in a new object that exposes its properties:
This is typically referred to as composition: B is composed of A, rather than inheriting from it.