Thursday, February 09, 2006

Definition of the week

Yesterday I read a very interesting statement:

"A class is a pointer to an object"

I think this definition really describes the relationship between classes and objects quite well for some languages. The language in question was Delphi. In Delphi, just like Java, C# and Visual Basic .NET, a class type would be referred to as a reference type. What does this mean? A variable of this type is a reference to an object, not the object itself. Or in other words, a class is a pointer to an object. If we could define an object, a class would just be a pointer to that type i.e.

PersonObj = object
...
end;

Person = ^object;

1 comment:

Andrew Cain said...

Ok there is also an object type in Delphi, so this is actually possible. You define an object using the object type. A variable of this type is the object, I assume stack based.