Solved

Instance of object of ancestors

Posted on 1999-01-08
3
235 Views
Last Modified: 2013-11-23
if i have one ancestor name Form1 and two descendants derived from Form1 name Form2 and Form3, when the application is running the Form2 and Form3 is created, does this two Forms use the same instance of object of ancestors(Form1) ? or it will create the new instance object of ancestors(Form1) for each of them(Form2 and Form3) ?
0
Comment
Question by:dumper
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 30 total points
Comment Utility
Form inheritance works in exactly the same way as class inheritance. When form2 and form3 are created they essentially call their inherited constructors (which correspond to Form1).

The end result is that there are no instances of form1, merely an instance of form2 and form3 (which are really just classes derived from form1).

Does this clear it up for you?

Cheers,

Raymond.
0
 

Author Comment

by:dumper
Comment Utility
so if i access the variable value in Form1 from Form2, the value will be the same as access from Form3,right ? so Form2 and Form3 is sharing the same instance of Form1 ?
0
 

Expert Comment

by:qdyoung
Comment Utility
No. There is no instance of TForm1. If you access variable Form1 in Unit1.pas, then you will get assignment error. If TForm1 has a public property named P. The TForm2 instance Form2 in Unit2.pas can assign it to 'ValueA', the TForm3 instance Form3 in Unit3.pas can assign it to 'ValueB' without effect Form2.P
  TForm is also just a VCL class, an object. You can refer to some Object-Oriented tech information.

Regards, Young.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now