|
-
Apr 19th, 2004, 08:30 AM
#1
Thread Starter
Frenzied Member
Inheritance woes [RESOLVED]
Ok, I have a base class and a derived class.
I have to be able to 'reset' the fields back to default settings by using a method. The base class has different fields than the derived class but I need to 'reset' all of them from one method. If I create the method in the base class, it will generate a compile error cause those fields don't exist in the derived class. what Is the best solution here?
Last edited by Andy; Apr 19th, 2004 at 08:50 AM.
-
Apr 19th, 2004, 08:35 AM
#2
Hi.
I guess I would make an overridable sub in the main class, responsible for resetting the fields that it knows about.
Then override the sub in the derived class, where the first call would be e.g. Mybase.ResetFields. Then I would reset the remaining fields.
Should you ever derive a third class with even more fields, then it's easy to let the base reset it self, and then just reset the new fields.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Apr 19th, 2004, 08:42 AM
#3
Thread Starter
Frenzied Member
ok, so I was on the right track..good
in the base class, I need a method that resets IT's fields, then, in the derived class, have a method call upon the base class like so: mybase.methodname here...is that right? AND have the derived class' method reset IT's fields as well?
-
Apr 19th, 2004, 08:45 AM
#4
Exactly.
This way you can inherit from the derived class as well, and still only add code to reset the new fields.
And you can inherit form that and from that and from that etc. etc.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Apr 19th, 2004, 08:50 AM
#5
Thread Starter
Frenzied Member
Nice....I am finally getting the hang of OOP. I am getting cold chills!!! lol
Thanks Pax!!
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
|