Member Avatar for Thew

Hello,
I have a small question. I have done some projects in C++ and Delphi. In C++, when I work with classes, I always use pointers.I make functions and classes that takes pointer to a class as an argument. But in Delphi, like this example:
(some class).Create(Owner: TComponent)
function take TComponent not ^TComponent, so i'm a bit confused about what actually happens when I create this object. Is whole Owner object copied for the function?
I'm sory if this question seems stupid, but I learned Delphi myself without using books etc., so I'm not quite sure how does it work.
Which option is better and faster:
procedure someFunction(Obj: TObject);
procedure someFunction(Obj: ^TObject);
procedure someFunction(var Obj: TObject);

Thanks.

For class types the parameter is passed by reference so you do not need to use a pointer. Passing a string or integral value that you want to modify in a delegate would require you using pointers or by reference -- but not for TObject. In this case they are identical as far as functionality, just different on how you treat the parameter.

Member Avatar for Thew

Thank you... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.