|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to require inherited class to include an enum?I was hoping to code a base class that would somehow require inheriting
classes to define an Enum. Each inheriting child class needs to define it's own enum with it's own enumerated values, which are unique for that child class. I can't find a way for a base class to required this. Any ideas? TIA Hello RJ,
HA! That would seriously violate the rules of inheritance. And even if you could somehow violate these rules.. you now have a violation with the ..NET type checking. Your base class can not require an inherited class to implement it's own enum. Just not possible. Either define an enum on the base class that includes all possible values... or redesign the mechanism that uses the enum so it no longer uses an enum... or move the entire enum-requiring mechanism outside the pervue of the base class. -Boo Show quoteHide quote > I was hoping to code a base class that would somehow require > inheriting classes to define an Enum. Each inheriting child class > needs to define it's own enum with it's own enumerated values, which > are unique for that child class. I can't find a way for a base class > to required this. Any ideas? > > TIA > RJ wrote:
> I was hoping to code a base class that would somehow require inheriting No can do. A base class has remarkably /little/ control over what a > classes to define an Enum. subclass /has/ to do. > Each inheriting child class needs to define it's own enum with it's own Why? What would you expect the subclasses to /do/ with this Enum about > enumerated values, which are unique for that child class. which the base class knows nothing? > I can't find a way for a base class to required this. Probably because there isn't one.Take a step back and tell us what you're trying to achieve and we'll see if we can suggest anything. :-) HTH, Phill W.
How to create a report (invoice)?
File operation with user-set wildcards Q: deleting relations DirectX rendered inside a control? problem save and reading from the registry Using SQLDataSource without a control? Problems with SaveAs Current namespace, stack and lineno How to make double click event to call and execute the mouseup event code Database |
|||||||||||||||||||||||