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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class inheritance

Status
Not open for further replies.

richasr1

Programmer
Dec 25, 2007
6
GB
Hi, i'm relatively new to C++, though i've been working with one form each time I use C++ Builder, i'd now like to branch out a bit more.

For example I wish to implement a second unit to contain methods and functions that would be best left out of the main form.

The only thing is i'm currently unable to link the two together, i'm guessing the main form's header file requires the new unit's header file as an #include but then how do I refer to the different methods included in the new unit?

I'm quite stumped!
 
This is how it worked on the older BCB (version 6 and older); once you had your main form open in BCB, click on "File," then click on "Include Unit Hdr." If the second form is already open, it's header file will be shown. If not, you may have to hunt for it. Double click on the other form's header file and it will link the two.




James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Ah thank you, tis very simple when you look around. Unfortunately i'm still haven't trouble referring to objects on form 1 from form 2.

I'm creating an object in form 2 and it's parent will be on form 1, i'm sure that used to be:

object->parent = frmname->object;

but this throws up errors stating there is no such thing as frmname and no such thing as object.

Baffled!
 
i should also state that, form 2 will not be visible in the final application, it's just a place to store certain parts of code.

Also, when I do what you said for the second form, multiple declaration errors appear for the methods i've created.
 
Couple of things jump to my mind. Did you open the second form and include the first form's header?

Second, did you make certain that the second form is auto-created? (Projects, then options, them the Forms tab. This is the usually the default.)


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
What i initially did was look in the Explorer on the right, right clicked the .exe and add new>Unit

Then i added in all the code, the new class and a method without including the first header and when i do come to do that, it gives me the following errors:

Multiple declaration for 'TClassUpdate'
and
Earlier declaration of 'TClassUpdate'

Very strange and i've not come across those particluar errors before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top