C
cosmocat
Hi all
I'm a newbie in C++Builder and I need and advice about the way of
instatiating a class in order to have a scope gobal to my form
On my form, I have 2 Buttons
Button_initialise : Instanciate the class whit a parameter for the
constructor
Button_callMethod : Use a property from the class
So my code looks like:
Declaration of myclass---------------------------------
Class Myclass
}
public:
Myclass(AnsiString AccountNumber) //Constructor
__property Int Aproperty = { read=PProperty };
}
code of form 1--------------------------------------
void TForm1:Button_initialiseClick(Tobject *Sender)
//----------first proc
{Myinstance Myclass("Parameter"); // Instanciate the class}
void TForm1:Button_callMethodClick(Tobject *sender)
//----------Second proc
{Int Value=Myinstance.Aproperty; //Use the class}
Of course, the compilation hangs on
void TForm1:Button_callMethodClick(Tobject *sender)
Because Myinstance is not declared in this proc
Here is My question
Where (and how) should I declare Myinstance in order to have her
visible in the
second proc, The constraint is that the parameter is unknew util user
clik button1 in proc 1
For example, Myclass could be a accountmanager and i need to ask the
user for the account number before instanciate it
Thanx for answering
I'm a newbie in C++Builder and I need and advice about the way of
instatiating a class in order to have a scope gobal to my form
On my form, I have 2 Buttons
Button_initialise : Instanciate the class whit a parameter for the
constructor
Button_callMethod : Use a property from the class
So my code looks like:
Declaration of myclass---------------------------------
Class Myclass
}
public:
Myclass(AnsiString AccountNumber) //Constructor
__property Int Aproperty = { read=PProperty };
}
code of form 1--------------------------------------
void TForm1:Button_initialiseClick(Tobject *Sender)
//----------first proc
{Myinstance Myclass("Parameter"); // Instanciate the class}
void TForm1:Button_callMethodClick(Tobject *sender)
//----------Second proc
{Int Value=Myinstance.Aproperty; //Use the class}
Of course, the compilation hangs on
void TForm1:Button_callMethodClick(Tobject *sender)
Because Myinstance is not declared in this proc
Here is My question
Where (and how) should I declare Myinstance in order to have her
visible in the
second proc, The constraint is that the parameter is unknew util user
clik button1 in proc 1
For example, Myclass could be a accountmanager and i need to ask the
user for the account number before instanciate it
Thanx for answering