Index:
[thread]
[date]
[subject]
[author]
From: Jason Grosland <jcg3@cs.duke.edu>
To :
Date: Fri, 12 Mar 1999 01:34:59 -0500
Re: inheritence
On Thu, 11 Mar 1999, Brijal Harshadray Padia wrote:
> class Option
> {
> public:
> virtual void doOption(Scandir & scanner)const = 0;
> };
> we were wondering if it was possible to declare two virtual void
> doOption functions in Options and then for the subclasses to inherit
> the appropriate one.
You might think of a few options for this...
* have a series of doOption functions in the parent class, and each
inherited class would have to implement all of them-- and you only code
for one, or return error codes if one of the options isn't valid for that
class.
* have a function/series of functions that aren't doOptions-- have
doOption call another function with the parameters it needs, or just have
your code call these other functions.
* have different parent classes for the different options that you're
thinking about passing to doOption. This would be effective if you only
had two ways of calling it, but several classes that you wanted to
implement in either one.
You do need to think about why you're doing this though. A doOption
function in a parent class is useful so you can do stuff like this:
Option * foo = getOptions();
foo->doOption(myScanner);
If you're thinking about different prototypes for the doOption, then you
wouldn't have this ability.
Think about what you're trying to accomplish, and what tools you want to
apply to get the job done.
Good luck,
-Jason
- 66 days and counting until I face reality... (days till Graduation) -
- jcg3@cs.duke.edu shanty.dorm.duke.edu www.duke.edu/~jcg3 -
Index:
[thread]
[date]
[subject]
[author]