Chapter 2. Hardware Fundamentals

Like any complex tool, the computer can be understood on several levels. For example, it's entirely possible to learn to drive an automobile without having the slightest idea how it works. The analogy with computers is that it's relatively easy to learn how to use a Web browser without having any notion of how such programs work. On the other hand, programming is much more closely analogous to designing an automobile than it is to driving one. Therefore, we're going to have to go into some detail about the internal workings of a computer, not at the level of electronic components, but at the lowest level accessible to a programmer.

This is a book on learning to program in C++, not on how a computer works.[1] Therefore, it might seem better to start there and eliminate this detour, and indeed many (perhaps most) books on C++ do exactly that. However, in working out in detail how I'm going to explain C++ to you, I've come to the conclusion that it would be virtually impossible to explain why certain features of the language exist and how they actually work, without your understanding how they relate to the underlying computer hardware.

[1] For a really in-depth (or at least very funny) explanation of how computers work, you might want to take a look at Dave Barry in Cyberspace (ISBN 0-517-59575-3).

I haven't come to this position by pure logical deduction, either. In fact, I've worked backward from the concepts that you will need to know to program in C++ to the specific underlying information that you will have to understand first. I'm thinking in particular of one specific concept, the pointer, that is supposed to be extremely difficult for a beginning programmer in C++ to grasp. With the approach we're taking, you shouldn't have much trouble understanding this concept by the time you get to it in Chapter 7, “Creating a Homegrown string class”. I'd be interested to know how you find my explanation, given the background that you'll have by that point. Don't hesitate to e-mail me about this topic (or any other, for that matter).

On the other hand, if you're an experienced programmer a lot of this will be just review for you. Nonetheless, it can't hurt to go over the basics one more time before diving into the ideas and techniques that make C++ different from other languages.[2]

[2] Some people believe that you should learn C before you learn C++. Obviously, I'm not one of those people; for that matter, neither is the inventor of C++, Bjarne Stroustrup,. On page 169 of his book, The Design and Evolution of C++, he says “Learn C++ first. The C subset is easier to learn for C/C++ novices and easier to use than C itself.”

Now let's begin with some definitions and objectives.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset