0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Thew
0

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.

0

Thank you... :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.