User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,596 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,698 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:

using method or dereferenced object pointer

Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,809
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 184
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: using method or dereferenced object pointer

  #2  
May 12th, 2008
In Delphi (as in C++, etc.), a reference is really a veiled pointer. Hence, when you declare a variable of type
var TMyObject: MyObject;
space is not reserved for the entire object; rather, MyObject is a pointer to a TMyObject.

The compiler is smart enough to know the difference, but allows for the possibility that the programmer knows something it doesn't when you use the second syntax you illustrated. However, unless you really do know something funny about your variable, you should stick to the first syntax.

Hope this helps.
Reply With Quote  
All times are GMT -4. The time now is 11:37 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC