Hi,
I like to know why in a enum the inizializator has to be fully
qualified even if it belongs to the enumeration.
Many thanks.
Marco.
//--- code
#include "stdafx.h"
using namespace System;
enum class ENUM_ID_TIPO_NODO
{
TNP_MIN = 0x80,
TNP_1 = ENUM_ID_TIPO_NODO::TNP_MIN, // ok
//TNP_1 = TNP_MIN, // error C2065: undeclared identifier
TNP_2,
TNP_3,
TNP_4,
TNP_5,
TNP_MAX
};
int _tmain()
{
ENUM_ID_TIPO_NODO en = ENUM_ID_TIPO_NODO::TNP_MIN;
return 0;
} 1 1550
marco_segurini wrote: Hi,
I like to know why in a enum the inizializator has to be fully qualified even if it belongs to the enumeration.
Many thanks. Marco.
//--- code #include "stdafx.h"
using namespace System;
enum class ENUM_ID_TIPO_NODO { TNP_MIN = 0x80, TNP_1 = ENUM_ID_TIPO_NODO::TNP_MIN, // ok //TNP_1 = TNP_MIN, // error C2065: undeclared identifier TNP_2, TNP_3, TNP_4, TNP_5, TNP_MAX };
int _tmain() { ENUM_ID_TIPO_NODO en = ENUM_ID_TIPO_NODO::TNP_MIN;
return 0; }
The code converted to C++/CLI:
enum class ENUM_ID_TIPO_NODO
{
TNP_MIN = 0x80,
TNP_1 = ENUM_ID_TIPO_NODO::TNP_MIN,
TNP_2,
TNP_3,
TNP_4,
TNP_5,
TNP_MAX
};
int main()
{
ENUM_ID_TIPO_NODO en = ENUM_ID_TIPO_NODO::TNP_MIN;
return 0;
}
Regarding the qualification, I guess it follows the syntax of a class:
class SomeClass
{
public:
static const int x=7;
};
// ...
int x = SomeClass::x;
--
Ioannis Vranos This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven T. Hatton |
last post by:
Any opinions or comments on the following? I don't say it below, but I came
out on the side of using enumerations over static constants.
/* I'm trying to figure out the pros and cons of using...
|
by: Tony Johansson |
last post by:
Hello!!
I have noticed that when you have defined some enum in the class definitions
these are called as if they were class members. Why is it not possible to
access enum BLACK and WHILE by...
|
by: Don |
last post by:
How do I get an Enum's type using only the Enum name?
e.g.
Dim enumType as System.Type
Dim enumName as String = "MyEnum"
enumType = ???(enumName)
|
by: cartoper |
last post by:
I am writing C# code that interacts with a external device's firmware
which is writen in C. There is a common enum file the firmware code is
using that I would like to consume in the C# world. I...
|
by: Edward Diener |
last post by:
In Managed C++ in order to share the functionality of a class between
its CLR code and native C++ code, in essence mixed mode programming for
a class, I would design the __gc class so its...
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code...
|
by: Cmtk Software |
last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI
managed c++ and from C#.
I defined the following enum in a VS dll project set to be compiled with the
/clr switch:
...
|
by: Dragan |
last post by:
Hi,
We're working in VS 2005, Team edition, if it makes any difference at
all (should be up-to-date and all that, but could not guarantee it is
100%).
We've implemented a simple generic wrapper...
|
by: Howard Swope |
last post by:
This problem has been bugging me for a while. I have created a collection
class and implemented it in a C# library. If I inherit from this class in
another C# assembly and it works, but if I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |