12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creat<strong>in</strong>g Applications <strong>in</strong> <strong>C++</strong>Builder<br />

Inherit<br />

The Inherit method of usage is similar to Copy, but with one important dist<strong>in</strong>ction: The new<br />

object is still tied to the base object. If you modify the base object, the newly created object<br />

will be updated to reflect the changes made to the base object. The <strong>in</strong>verse is not true,<br />

however. You can modify the new object without it hav<strong>in</strong>g any effect on the base object.<br />

To illustrate this type of object usage, consider the follow<strong>in</strong>g scenario: Frequently, <strong>in</strong>formation<br />

managers will create a spreadsheet <strong>in</strong> a spreadsheet program and use the contents of that<br />

spreadsheet <strong>in</strong> a word process<strong>in</strong>g program <strong>in</strong> order to present a report. They will usually opt<br />

to l<strong>in</strong>k the data to the spreadsheet when past<strong>in</strong>g from the Clipboard or import<strong>in</strong>g the<br />

spreadsheet <strong>in</strong>to the word processor. That way, when changes are made to the spreadsheet,<br />

the word process<strong>in</strong>g document is automatically updated to reflect the new data. In the same<br />

way, changes made to a base form will automatically be reflected <strong>in</strong> all forms <strong>in</strong>herited from<br />

the base form. Use the Inherit option when you want to have several forms based on a<br />

common form that might change at some po<strong>in</strong>t. Any changes <strong>in</strong> the base form will be<br />

reflected <strong>in</strong> all <strong>in</strong>herited forms.<br />

Use<br />

The Use option is not common. When you use an object, you are open<strong>in</strong>g that object directly<br />

for edit<strong>in</strong>g. Use this option when you have saved an object <strong>in</strong> the Repository and you want<br />

to make permanent changes to that object. In the section “Inherit” I said that changes made<br />

to a base form would be reflected <strong>in</strong> all <strong>in</strong>herited forms. If you wanted to make changes to<br />

a base form, you would open it <strong>in</strong> the Object Repository with the Use option.<br />

Now What?<br />

Exactly what takes place when you select an object from the Object Repository depends on<br />

several factors. The factors <strong>in</strong>clude the type of object selected, whether a project is currently<br />

open, and the usage type you have selected (Copy, Inherit, or Use). If you have an application<br />

open and you choose to create a new application from the Object Repository, you will be<br />

prompted to save the current project (if necessary) before the new project is displayed.<br />

TIP<br />

Choos<strong>in</strong>g File | New Application from the ma<strong>in</strong> menu is a shortcut for<br />

start<strong>in</strong>g a new application. It is equivalent to choos<strong>in</strong>g New from the<br />

ma<strong>in</strong> menu and then choos<strong>in</strong>g the Application object from the Object<br />

Repository. Similarly, the New Form, New Data Module, and New<br />

Unit items on the ma<strong>in</strong> menu are shortcuts for their equivalents <strong>in</strong> the<br />

Object Repository.<br />

321<br />

9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!