473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to require inherited class to include an enum?

RJ
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
Aug 25 '06 #1
2 1207
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
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


Aug 25 '06 #2
RJ wrote:
I was hoping to code a base class that would somehow require inheriting
classes to define an Enum.
No can do. A base class has remarkably /little/ control over what a
subclass /has/ to do.
Each inheriting child class needs to define it's own enum with it's own
enumerated values, which are unique for that child class.
Why? What would you expect the subclasses to /do/ with this Enum about
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.
Aug 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Thomas Matthews | last post by:
Hi, I am converting my table and record classes into templates. My issue is the syntax of declaring a friend class within the template. I have searched the C++ FAQ Lite (web), the C++...
3
by: Alicia | last post by:
Hello, I am trying to figure out how to call an overloaded operator<< inherited from a base class. #ifndef PHONECALL #define PHONECALL #include "time.h" #include "interval.h"
3
by: yancheng.cheok | last post by:
hello all, how can i make, a forward declaration class's enum member, being visible by another class? consider the following case, ---------------------------- dog.h...
3
by: Dan Holmes | last post by:
Say i have: public class A { } public class B : A {
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.