Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic question about Object Pascal 1

Status
Not open for further replies.

jjschwartz

Technical User
Feb 3, 2004
23
US
I'm currently learning Delphi and Object Pascal after many years with other languages. I seem to have a basic misunderstanding.

The prototypical code that's in the first chapter of every book is:

unit Unit1;
type
TForm1 = class(TForm) { The type declaration of the form begins here }
end; { The type declaration of the form ends here }

var
Form1: TForm1;

implementation { Beginning of implementation part }
end. { End of implementation part and unit}

It seems I make a new class, TForm1, that is a descendant of TForm. Then I create Form1, an instance of the class TForm1.

Why do I have to create a new class TForm1? Why can't Form1 be an instance of TForm?

TIA
Jeff Schwartz
 
if you want to create an instance of TForm, you're free do to do so, but this way you only get a Form in its default state, this means no extra controls on it, default properties. that's why delphi doesn't make instances of its source objects, since the point of it all is to "modify" the source object (adding a button, an event,...). this means that TForm1 will inherit all properties and event TForm has but will also include all the "added" objects.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top