?
Solved

Instance of object of ancestors

Posted on 1999-01-08
3
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 120 total points
ID: 1355432
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
ID: 1355433
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
ID: 1355434
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

800 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