|
-
Apr 19th, 2003, 01:55 AM
#1
Thread Starter
Registered User
classes and inheritance
hi,
Is it possible to inherit another class, but hide all the base classes objects from the users that instantiate our class, i mean so when are object was created , users can access only the events,methods and properties of our class and not the base classes.
( we should still be able to use the base class methods from in our own program, anyway thats why we inherited it )
-
Apr 19th, 2003, 02:34 AM
#2
I don't think so, if that is the case then you should just keep a private object of the type you want to inherit. Then you can pick only the properties and what not that you want to expose and hide the others since you aren't actually inheriting anything. Then if you need a method of something from the base class just use the internal private object. Of course that means that the class would not be able to pass as a decendant anymore since it wouldn't be inherited. In other words if you wanted to inherit Listbox and a method called for a listbox argument then your class couln't be passed, unless it was inheriting Listbox.
-
Apr 19th, 2003, 03:57 AM
#3
Thread Starter
Registered User
-
Apr 19th, 2003, 02:23 PM
#4
yay gay
no..thats a feature that c++ has and C# and vb.net doesnt have.. although sometime ago i mailed the C# team and they said they would research if they could implement it in C# or not
\m/  \m/
-
Apr 19th, 2003, 04:41 PM
#5
PowerPoster
If you are designing the base class yourself, make the members protected.
-
Apr 21st, 2003, 07:39 AM
#6
Fanatic Member
Yeah, that was my thought too - make the base class proterties, etc. protected.
-
Apr 22nd, 2003, 05:36 AM
#7
Lively Member
Instead of creating a class inheriting from the base class, have the 'base' class as a private member variable of your class.
Code:
Public Class xyz
Private hiddenClass as myOtherClass
Public Sub mySub()
' Can call public members of hiddenClass here, no one outside the object will be able to.
hiddenClass.aSub()
End Sub
End Class
You can do this if the base class is not your own code so you don't expose the other classes code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|