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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6<br />

174 Day 6<br />

WARNING<br />

Source Code Units<br />

Do not delete any files from the <strong>C++</strong>Builder directories other than the<br />

Examples directory. If <strong>in</strong> doubt, don’t delete!<br />

Earlier I mentioned that most applications of any size have several source files, which <strong>Borland</strong><br />

calls units. The use of the term unit <strong>in</strong> <strong>C++</strong>Builder is a holdover from Pascal and Delphi.<br />

<strong>C++</strong>Builder has its roots <strong>in</strong> the Delphi IDE, and unit is used throughout both VCL and the<br />

<strong>C++</strong>Builder IDE itself. <strong>C++</strong> programmers would typically refer to a file conta<strong>in</strong><strong>in</strong>g a<br />

program’s source as a module. While us<strong>in</strong>g the term module would have been more <strong>C++</strong><br />

friendly (and less Pascal-like), replac<strong>in</strong>g the word unit with module would have required<br />

major changes to the <strong>C++</strong>Builder <strong>in</strong>frastructure, so the term unit was left <strong>in</strong>. If you are<br />

com<strong>in</strong>g from a <strong>C++</strong> programm<strong>in</strong>g background, it might seem odd to refer to modules as<br />

units, but you will get used to it soon enough. In the end, there’s no po<strong>in</strong>t <strong>in</strong> gett<strong>in</strong>g hung<br />

up over term<strong>in</strong>ology.<br />

<strong>C++</strong>Builder uses the term unit to refer to source files.<br />

NEW TERM<br />

NOTE<br />

Each time you create a new form, <strong>C++</strong>Builder does the follow<strong>in</strong>g:<br />

■ Creates a form file (.DFM)<br />

■ Derives a class from TForm or from another form class<br />

■ Creates a header (.H file) conta<strong>in</strong><strong>in</strong>g the class declaration<br />

■ Creates a unit (.CPP file) for the class def<strong>in</strong>ition<br />

■ Adds the new form <strong>in</strong>formation to the project makefile<br />

Initially <strong>C++</strong>Builder assigns the default name Form1 to the form, Unit1.cpp for the associated<br />

unit, and Unit1.h for the header. The second form created for the project would have the<br />

default name Form2, and so on.<br />

As soon as you create a new project, you should save it with a mean<strong>in</strong>gful<br />

name. Likewise, every time you create a new form, you should save<br />

it with a descriptive name. This makes it easier to locate forms and<br />

units when you need to make modifications.

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

Saved successfully!

Ooh no, something went wrong!