![]() |
| ||
| using method or dereferenced object pointer I would like to ask whether pointer dereference by typecast is same in both cases: TComponent(my_tfplist[1]).mymethodand TComponent(my_tfplist[1]^).mymethod both things are doing the same thing (at least it behaves so), but compiler generates different code, so i'm curious what is the difference between those two. to clarify: my_tfplist is an object instance of class tfplist (or tlist, doesn't matter really). thanks |
| ||
| Re: using method or dereferenced object pointer 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. |
| ||
| Re: using method or dereferenced object pointer Quote:
thank you very much. |
| All times are GMT -4. The time now is 4:47 pm. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC