Originally Posted by
Super Vegeta
Am I the only person around here, who finds the it-is-a-pointer-but-not-exactly behaviour of classes confusing and uses objects instead?
If you are referring to using legacy "objects" (e.g. type TTest = object), then I would expect this functionality to be removed eventually (as far as I understand, it has been considered deprecated for quite some time now), at least in Delphi.
Originally Posted by
T-Bear
So i can do something like this:
var
Object: TObject;
ObjectPtr: TObject;
begin
Object:= TObject.Create;
ObjectPtr:= @Object;
end.
Im just wondering caus i need that kind of functionality, which is why i am using pointers in the first place.
Well, not exactly:
Code:
type
TMyClass = class // TObject is assumed as base class
end;
var
Object: TMyClass;
ObjectPtr: TMyClass;
begin
Object:= TMyClass.Create();
ObjectPtr:= Object; // now ObjectPtr has reference to Object
Object.Free; // now Object no longer exists, ObjectPtr contains invalid reference.
end.
Bookmarks