Undefined symbol using enum class

2.7k views Asked by At

This is probably a trivial question, but I am not able to overcome a problem with enum class data:

enum class enumTest
{
   VALUE0 = 0, VALUE1 = 1, VALUE2 = 2
};

void __fastcall TForm1::Button1Click (TObject* Sender)
{
int a = VALUE1;
}

I get: Error: Undefined symbol: 'VALUE1'

Changing enum class enum into:

enum //class enumTest

the compiler works normally.

Unfortunately I cannot do it because it is defined into the TLB/OCX include file, as many other declarations. This happens with different types of OCX of different vendors.

1

There are 1 answers

1
James McNellis On

An enum class is called a scoped enumeration. You need to use its enumerators in the scope of the enumeration. For example,

int a = enumTest::VALUE1;