| | |
Pointers - question
Thread Solved |
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.
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.
![]() |
Similar Threads
- database connection (Java)
- returning Pointers question (C++)
- Is array name equivalent to a pointer?? (C)
- Question regarding base class and derived class (C++)
- new to pointers question (C++)
- Completed Code but A LOT of GOTO...Replacement? (C++)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Could you express the meaning of the answer?
- Next Thread: Delphi character encoding
| Thread Tools | Search this Thread |






