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.

Gett<strong>in</strong>g Your Feet Wet<br />

An object, like components described earlier, is a piece of b<strong>in</strong>ary software that<br />

performs a specific programm<strong>in</strong>g task. (Components are objects, but not all objects<br />

are components. I’ll get <strong>in</strong>to that later.)<br />

An object reveals to the user (the programmer us<strong>in</strong>g the object) only as much of itself as<br />

needed <strong>in</strong> order to simplify its use. All <strong>in</strong>ternal mechanisms that the user doesn’t need to know<br />

about are hidden from sight. All of this is rolled up <strong>in</strong> the concept of object-oriented<br />

programm<strong>in</strong>g. OOP allows you to take a modular approach to programm<strong>in</strong>g, thus keep<strong>in</strong>g<br />

you from constantly re-<strong>in</strong>vent<strong>in</strong>g the wheel. <strong>C++</strong>Builder programs are OOP-oriented due to<br />

<strong>C++</strong>Builder’s heavy use of components. Once a component is created (either one of your own<br />

or one of the built-<strong>in</strong> <strong>C++</strong>Builder components), it can be reused <strong>in</strong> any <strong>C++</strong>Builder program.<br />

A component can also be extended by <strong>in</strong>heritance to create a new component with additional<br />

features. Best of all, components hide their <strong>in</strong>ternal details and let the programmer<br />

concentrate on gett<strong>in</strong>g the most out of the component. Objects and <strong>C++</strong> classes are discussed<br />

<strong>in</strong> detail on Day 4, “Totally Immersed: <strong>C++</strong> Classes and Object-Oriented Programm<strong>in</strong>g.”<br />

NEW TERM<br />

Humble Beg<strong>in</strong>n<strong>in</strong>gs<br />

In the beg<strong>in</strong>n<strong>in</strong>g there was C…as far as <strong>C++</strong> is concerned, anyway. <strong>C++</strong> is built on the C<br />

programm<strong>in</strong>g language. It has been described as “C with classes.” This foundation <strong>in</strong> C is still<br />

very prevalent <strong>in</strong> <strong>C++</strong> programs written today. It’s not as if <strong>C++</strong> were written to replace C,<br />

but rather to augment it. The rest of this chapter and much of the next chapter focus primarily<br />

on the part of the <strong>C++</strong> language that has its roots <strong>in</strong> C. Actually, we will be deal<strong>in</strong>g with the<br />

C language here and mov<strong>in</strong>g to <strong>C++</strong> later, on Day 2, “Wad<strong>in</strong>g In Deeper.” You don’t have<br />

to be concerned with which of the <strong>in</strong>formation presented is from C and which is from <strong>C++</strong><br />

because it’s all rolled up <strong>in</strong>to the language we call <strong>C++</strong>.<br />

It would be nice if present<strong>in</strong>g the <strong>C++</strong> language could be handled sequentially. That’s not<br />

the case, though, because all of the features we will be discuss<strong>in</strong>g are <strong>in</strong>tertw<strong>in</strong>ed. Present<strong>in</strong>g<br />

the <strong>C++</strong> language sequentially is not possible, so I’ll take the <strong>in</strong>dividual puzzle pieces one at<br />

a time and start fitt<strong>in</strong>g them together. Toward the end of Day 3, “Up to Your Neck <strong>in</strong> <strong>C++</strong>,”<br />

you’ll have a fairly complete picture of the <strong>C++</strong> language. Don’t be concerned if you do not<br />

<strong>in</strong>stantly grasp every concept presented. Some of what is required to fully understand <strong>C++</strong><br />

can only come with real-world experience.<br />

Variables<br />

Well, we have to start somewhere, so let’s take a look at variables. A variable is essentially a<br />

name assigned to a memory location. Once you have declared a variable, you can then use<br />

it to manipulate data <strong>in</strong> memory. That probably doesn’t make much sense to you, so let me<br />

15<br />

1

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

Saved successfully!

Ooh no, something went wrong!