Inheriting Methods

gamalima

New member
Joined
Feb 22, 2006
Messages
2
Programming Experience
1-3
I have one class that inherits another class. The base class has some private variables, but it also has public methods that access those variables. Is there anyway that I could make it so those methods aren't inherited, while at the same time, keeping them accessable? Here's an example, in case I'm not making sense

Private loginCheck as Boolean
...
Public Function getLoginCheck() as Boolean
Return loginCheck
End Function
...
Public Sub setLoginCheck(ByVal iLoginCheck as Boolean)
loginCheck = iLoginCheck
End Sub

This is from the base class. So the derived class has no loginCheck variable, but still has the getLoginCheck and setLoginCheck methods. Is there anyway to fix that, or do I have to override those methods in the derived class and declare them private?
 
If your inheriting this class then all the methods will be available in the derived class unless you make them explicitly private. I'm presuming that you want these methods available to other derived classes so you can't make them private. So i do find myself asking why you want to inherit this class?
 
If you have to hide public members in a derived class, you'll have to reconsider your design. The "fix" you are asking for is bad design.

I also do not understand what you mean by "keeping them accessable". Care to elaborate on that?
 
There are several other methods and variables that I do want it to inherit, but your question did make me realize that I'm going about it the wrong way. The best solution, at least the way I see it now, would be to take both the current base class and the derived class and make them both derived classes of the same base class, which would contain the methods and variables I need in both of them, while allowing me to keep public methods out of the class I don't want them to be in. I really can't believe I didn't see that before.
 
Back
Top