Pointers - question

Thread Solved

Join Date: Jan 2008
Posts: 53
Reputation: Thew is an unknown quantity at this point 
Solved Threads: 0
Thew's Avatar
Thew Thew is offline Offline
Junior Poster in Training

Pointers - question

 
0
  #1
Jul 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,210
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Pointers - question

 
0
  #2
Jul 9th, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 53
Reputation: Thew is an unknown quantity at this point 
Solved Threads: 0
Thew's Avatar
Thew Thew is offline Offline
Junior Poster in Training

Re: Pointers - question

 
0
  #3
Jul 9th, 2009
Thank you...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC