Board index » cppbuilder » Enum question

Enum question


2003-12-04 07:10:51 AM
cppbuilder90
with regards to the post "The trouble with enum and ints" ...
does someone here know why we have to check "Treat enums as int"
to get the correct enum value when converting a vcl to activex?
it's just that even if i assign values to the enum, BCB still
doesn't recognize it. someone pls explain the behavior of enums
in BCB ... thanks.
 
 

Re:Enum question

How accessing an enum varaiable from another class:
class TNodeProperties : public TObject
{
enum TypeNoeud{FOLDER=0,DOCUMENT};
TypeNoeud TypeNode;
AnsiString ItemTitle;
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TNodeProperties *pNodeProp=new TNodeProperties();
//*ERROR: FOLDER is unknown here by the compiler*
pNodeProp->TypeNode=FOLDER;
//-----------------------------------------------------------
}
What I need to do for assign the value FOLDER to pNodeProp->TypeNode ?
Sam
 

Re:Enum question

On Tue, 9 Aug 2005 11:58:05 +0200, sam wrote:
Quote
//*ERROR: FOLDER is unknown here by the compiler*
pNodeProp->TypeNode=FOLDER;
Currently members TNodeProperties are prIvate. They are not
accessible from TForm1.
--
liz
 

{smallsort}

Re:Enum question

sam wrote:
Quote
How accessing an enum varaiable from another class:
class TNodeProperties : public TObject
{
enum TypeNoeud{FOLDER=0,DOCUMENT};
TypeNoeud TypeNode;
AnsiString ItemTitle;
};
First of all, you make your enum public:
class TNodeProperties : public TObject
{
public:
enum TypeNoeud{FOLDER=0,DOCUMENT};
}
Quote
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TNodeProperties *pNodeProp=new TNodeProperties();
//*ERROR: FOLDER is unknown here by the compiler*
pNodeProp->TypeNode=FOLDER;
//-----------------------------------------------------------
}
Here you have to specify the namespace of enum (TNodeProperties::FOLDER):
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TNodeProperties *pNodeProp=new TNodeProperties();
pNodeProp->TypeNode=TNodeProperties::FOLDER;
}
 

Re:Enum question

Thank you very much for resolving my mistake.
Sam
"Muzaffar Mahkamov" < XXXX@XXXXX.COM >a écrit dans le message de
Quote
sam wrote:
>How accessing an enum varaiable from another class:
>class TNodeProperties : public TObject
>{
>enum TypeNoeud{FOLDER=0,DOCUMENT};
>TypeNoeud TypeNode;
>AnsiString ItemTitle;
>};
First of all, you make your enum public:

class TNodeProperties : public TObject
{
public:
enum TypeNoeud{FOLDER=0,DOCUMENT};
}

>void __fastcall TForm1::Button1Click(TObject *Sender)
>{
>TNodeProperties *pNodeProp=new TNodeProperties();
>//*ERROR: FOLDER is unknown here by the compiler*
>pNodeProp->TypeNode=FOLDER;
>//-----------------------------------------------------------
>}
Here you have to specify the namespace of enum (TNodeProperties::FOLDER):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TNodeProperties *pNodeProp=new TNodeProperties();
pNodeProp->TypeNode=TNodeProperties::FOLDER;
}