Enumerated types

Top  Previous  Next

What is translated > Types > Enumerated types


The explicit definition of enumeration types is easy to translate.


Day = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);  


enum Day {Mon, Tue, Wed, Thu, Fri, Sat, Sun };


However, an implicit definition is also possible in object Pascal within a variable declaration. It is decomposed for C++ into an explicit type definition and the real declaration of the variable. The name of the type is derived from the name of the unit by appending two underscores and a counter.


Day : (Mon, Tue, Wed, Thu, Fri, Sat, Sun);


enum test__0 {Mon, Tue, Wed, Thu, Fri, Sat, Sun };

test__0 Day;



If the size of an array is specified by an enumerated type, the size is evaluated from the smallest and greatest value of the type.




  TEnum = (cm1, cm2, cm3, cm4, cm5, cm6);



  foo : Array[TEnum] Of String;




enum TEnum {cm1, cm2, cm3, cm4, cm5, cm6 };

AnsiString foo [ 6 /*TEnum*/ ];


This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content