cosmocat wrote in news:28ccee3d.0310160007.26524af9@posting.google.com:
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
Well Form is unknown in Standard C++, but since I know a Form is
just a non-standard class, I'll take it from there.
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
[snip]
Somewhere you have something like:
#include "whatever"
//add:
#include <memory>
class TForm1: public TWhatever
{
//add:
std::auto_ptr< Myinstance > myinstance;
};
void TForm1:Button_initialiseClick(Tobject *Sender)
//----------first proc
{Myinstance Myclass("Parameter"); // Instanciate the class}
{
myinstance.reset( new Myinstance( "Paramiter" ) );
}
void TForm1:Button_callMethodClick(Tobject *sender)
//----------Second proc
{Int Value=Myinstance.Aproperty; //Use the class}
{
if ( myinstance.get() )
{
Int Value = myinstance->Aproperty;
}
else
{
// Error handling here ??
}
}
HTH
Rob.
--
http://www.victim-prime.dsl.pipex.com/
.