Subject Re: [IBO] Re: IBA_Statement.IMP ???
Author Jason Wharton
Geoff,

Thanks for clarifying this.

I sure did step into deep water on that one.

Apologies to all I may have misinformed.

Regards,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: "Geoff Worboys" <geoff@...>
To: <IBObjects@yahoogroups.com>
Sent: Thursday, February 01, 2001 4:52 PM
Subject: Re: [IBO] Re: IBA_Statement.IMP ???


> > You are correct that NEW is wrong here. You need to use
> > the object constructor, not a method that simply allocates
> > a chunk of memory the size of the object type.
>
> Sorry people, I had not been paying attention. Unless BCB5 has moved
> away from Ansi C++ compliance, the use of new/delete is correct. A
> bit of explanation for the Pascal people...
>
> C++ constructors take the form
> TClassName::TClassName( parameters)
>
> Notice that the constructor name is the same name as the class! There
> are no such functions a Create, and CreateNew etc. Instead, different
> constructors are identified via different parameters on overloaded
> constructor functions.
>
> So in BCB you construct using...
> NewPtr = new TClassName( parameters );
> and you destruct using...
> delete NewPtr;
>
>
> The BCB Pascal compiler takes care of converting constructor "Create"
> functions into overloaded TClassName(*) functions in the automatically
> generated header files.
>
>
> > > At 11:17 01.02.2001 -0000, you wrote:
> > > >Just to make things alittle bit clearer.
> > > >I want to do this in my program:
> > > >
> > > >TIB_Connection *Connection;
> > > >Connection = new TIB_Connection(NULL);
> > > >
> > > >TIB_Transaction *Trans;
> > > >Trans = new TIB_Transaction(Application);
> > > >
> > > >
> > > >This work throw the compilator. But when I run the
> > > >program, is the warning message "TIB_Transaction
> > > >needs a connection to work!", and asI said earlier
> > > >this is before the objects is being created. And then
> > > >does it put the cursor on a file (Delphi code) where
> > > >the warning message is being trown.
>
> Simon,
>
> I agree with Jason that it is generally safer to always provide an
> owner in your constructors, but I doubt if that is the reason for your
> problem.
>
> Your code should probably be something like...
>
> TIB_Connection *Connection = new TIB_Connection(Application);
> TIB_Transaction *Trans = new TIB_Transaction(Application);
> Trans->IB_Connection = Connection;
>
>
> If you are getting "TIB_Transaction needs a connection to work" before
> this code is called, then it must be because you are referencing a
> transaction (but certainly not "Trans" since it would not exist yet,
> so referencing it would cause an AV). In which case you may need to
> move where you have placed this code.
>
> HTH
>
> Geoff Worboys
> Telesis Computing
>
>
>
>
>