473,395 Members | 1,578 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,395 software developers and data experts.

Enums reference in C++

Hi,

I found some Visual C++ that looked like this:

enum colors { red, blue, green };

void f(void)
{
colors C;

C = colors::red /* Is this valid ?? */
}
Is the last assigment a valid C++ syntax? It looks as if defining an
enum also define a namespace of the same name.
This code doesnt compile with gcc. Is it some MS only extension or is
that defined in some revision of the C++ language spec ?

Thanks

-- Fox

Jul 23 '05 #1
2 1211
seems like a m$ extension to me (I only see it in Windows code)

Jul 23 '05 #2
fa*************@gmail.com wrote:
Hi,

I found some Visual C++ that looked like this:

enum colors { red, blue, green };

void f(void)
{
colors C;

C = colors::red /* Is this valid ?? */
}
Is the last assigment a valid C++ syntax? It looks as if defining an
enum also define a namespace of the same name.
This code doesnt compile with gcc. Is it some MS only extension or is
that defined in some revision of the C++ language spec ?

This looks like a managed enum of C++ "managed extensions" (.NET) and is not part of ISO C++.
With the upcoming C++/CLI and VS 2005, CLI types are provided with a separate syntax than
ISO C++ facilities, to reduce confusion and preserve semantics (now with managed
extensions is "on context" and is upon he programmer to know exactly what is going on).

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #3

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

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
5
by: DMitchell | last post by:
Is there any way of getting a public enumeration to be generated into a web service proxy?
2
by: Simon Elliott | last post by:
I have some legacy C++ code which requires some enums to be 1 or 2 bytes in size. I'd ideally like to be able to specify that a few carefully selected enums are a particular size. By default,...
2
by: David Veeneman | last post by:
I want to data bind a user control and a business object, using a BindingSource control. The control has a 'Priority' property that takes a 'Priority' enum (High, Normal, Low). The business object...
3
by: hardieca | last post by:
Hi, I'm starting out with C#, and I'm wondering if someone could tell me what is the difference between Enums and dictionaries... My book doesn't even make reference to dictionaries, but while...
11
by: Marc Gravell | last post by:
This one stumped me while refactoring some code to use generics... Suppose I declare an enum MyEnum {...} Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ? Of course,...
1
by: pistmaster | last post by:
Hi, I have a client server application which has various messages containing enums, ie I serialize classes of the form: class MyClass { MyEnum e; }
8
by: Daniel Gutson | last post by:
Hi, I just wanted to share another library for doing type-safe bitwise operations in C++: http://bitwise-enum.googlecode.com I found it useful, so hopefully it'll be for somebody else as well....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.