473,572 Members | 3,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ Enumeration Class

3 New Member
Yesterday I was in need for a more advanced form of enumeration in C++, something similar to Java Enumeration classes. But C++ only supports the basic C enum.

This can be fine for many things, but I am looking for a more sophisticated solution like the one in the Dr. Dobb's portal 2003 article "When enum Just Isn't Enough: Enumeration Classes for C++" at http://www.ddj.com/dept/cpp/184403955. It seems the link is wrong: the code is in a zip file at ftp://ftp.cuj.com/pub/2003/cujmay2003.zip (and then in meynard.zip).

I must say that I am fairly new in template programming but i get the basic idea of Yves Meynard's Enum templates.

I am on windows using MinGW (GCC 3.4.2) and the code simply will not compile. I am getting some compiler errors:

line 47 Enum.h type `std::set<const Enum<T>*, Enum<T>::Enum_P tr_Less, std::allocator< const Enum<T>*> >' is not derived from type `Enum<T>'

line 47 Enum.h ISO C++ forbids declaration of `size_type' with no type


I was wondering if anybody could give some advise on the code in the article - whether or not it will compile ever with gcc 3.4.2 in MinGW? What changes could I do such that it would work?

Thanks, kofler
Mar 20 '07 #1
0 1372

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Sergey Poberezovskiy | last post by:
Hi, I have a simple enumeration in my schema: <xs:element name="el_1"> <xs:simpleType> <xs:restiction base="xs:string"> <xs:enumeration value="value and space 1"/> <xs:enumeration value="value2 with spaces"/> ...
by: Barguast | last post by:
This is a trivial problem, but I'm just looking for a nice way to do it, that's all :) I've got an enumeration which enumerates a number of different text encodings, for example: public enum TextEncoding { ASCII, Unicode,
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation" for a second if you don't mind). However, it existed within intuitive language semantics, whereas the new "yield" keyword, while highly...
by: Sampson | last post by:
I have a question about enumeration and how to populate them during runtime. I am using vb.net but will happily take any advice in c# as well. Here is an example to help illustrate what I am after. Create a class named “clsMyItems” and in that class place an enum. Public Enum Items Item1 = 0 Item2 = 1 Item3 = 2
by: Don | last post by:
I need to get the type of an enumeration from an instance of a class. e.g. Public Class MyClass Public Enum MyEnum value1 = 1 End Enum End Class
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to provide a "one obvious way" to do enumerations in Python. > >>> from enum import Enum > >>> day = Enum('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
by: Nathan | last post by:
I'd like to use an enumeration as a datasource for a drop-down box. Is there a way to do this?
by: John Saunders | last post by:
Given a schema as follows: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="testEnum" type="TestEnumUse"/> <xs:complexType name="TestEnumUse"> <xs:sequence> <xs:element name="testEnum" type="TestEnumType"/>
by: Charlie | last post by:
Hi: How would I bind a list to an enumeration so that enumeration value becomes list values and enumeration constants becomes list text? Do you loop through enum and add manually or is there a way to databind like when using a table as list backing store? Thanks, Charlie
by: scotchfx | last post by:
Is there any way of declaring an enumeration in a base class in such a way that it can be "overridden" in a derived class... for instance: class Base{ public: enum Enum { //empty }; } class Derived : public Base{
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.