- Shopping Bag ( 0 items )
Ships from: acton, MA
Usually ships in 1-2 business days
Unlike the rest of the wimpy programming tutorials, this publication teaches you to write clean and solid C++ code. The author, Ivor Horton, doesn't just introduce and gloss over subjects, he covers them thoroughly. Although this introductory C++ tutorial covers programming basics, you should be somewhat familiar with programming concepts and object orientation.
In this first chapter, I will introduce the general characteristics of C++. All the concepts presented here will be covered in more detail in later chapters - this is just to set the scene before we get into the specifics of writing C++ programs. We will see what a simple C++ program looks like and how it all hangs together. We'll also be looking at the broad concepts of programming in C++, and how you create an executable program from the source code files you'll be writing.
Don't try to memorize all the information in this chapter. Concentrate on getting a feel for the ideas involved. Everything that is mentioned will come up again in later chapters, and you will learn best by using it, not just reading about it. In this chapter you will find out about:
You are probably familiar with the basic ideas of programming and programming languages, but to make sure we're on common ground, let's do a quick survey of some of the terms we'll be using as we progress through the book. We can also put C++ into perspective in relation to some of the other programming languages you'll have heard of.
Whatever the programming language, the programs you write are made up of separate instructions; these are referred to collectively as source code, and are stored on disk in a source file. There are lots of programming languages, each with their advantages and disadvantages, and their protagonists and detractors. Along with C++, other languages that you're likely to have come across include BASIC, COBOL, FORTRAN, Pascal and C.
FORTRAN, for example, is a language that's been around for nearly 40 years and is still used extensively for scientific and engineering calculations, although C++ and other languages have proded much of its usage. COBOL is a language exclusively for business data processing applications, and is almost as old as FORTRAN. While little new code is written in COBOL, there is an immense amount of code that was written years ago and is still in use. Again, C++ has become the language of choice for many business data processing programs.
C is the forerunner of C++, and because of this the two languages share a common set of syntax and functionality. In fact, the C programming language forms a subset of C++. However, the extensions and improvements that C++ provides have matured as the language has developed, and C++ is a richer and more versatile language than its ancestor, as we shall see.
Programming languages are designed to make it relatively easy for you to describe the actions you want a computer to carry out, compared with the form of program that a computer can actually execute. Your computer can only execute programs that consist of machine instructions (also called machine code), so it can't execute your program directly There are basically two ways in which a program written in one of the languages I mentioned above can get executed, and for the most part, a particular language will choose one or the other. Programs written in BASIC, for example, are usually interpreted - that is, another program called an interpreter inspects the BASIC source code, figures out what it is supposed to do, and then causes that to be done.
C++, on the other hand, is a compiled language. Before you can execute your C++ program, it must be converted to machine language by another program, called a compiler. The compiler inspects the C++ program and generates the machine instructions that will produce the actions specified by the source code. Of course, in reality neither interpreting nor compiling are quite as simple as I have described them here, but in principle that's how they work.
With an interpreted language, execution is 'indirect', by which I mean the intent of the source code needs to be determined each time a program is executed. For this reason, it is much slower - sometimes of the order of a 100 times slower - than the equivalent program in a compiled language. A given language is usually either compiled or interpreted, and it's typically the design and intended use of the language that determines which.
Something of an exception to this rule is Java, a relatively new language that has many of the characteristics of C++. Because it is intended to be portable across different computers and used on the Internet, Java is essentially an interpreted language. Having said that, there are also justin-time compilers that will produce the machine code equivalent portions of the original Java source as machine code programs at execution time, and thereby greatly enhance the execution speed.
If you had to create everything from scratch every time you wrote a program, it would be tedious indeed. The same kind of functionality is often required in many programs - reading data from the keyboard, for example, or displaying information on the screen. To address this, programming languages tend to come supplied with considerable quantities of pre-written code that provides standard facilities such as these, so you don't have to write the code for them yourself.
Standard code intended for use in any program is kept in a library. The library that comes with a particular programming language is as important as the language itself, as the quality and scope of the library can have a significant effect on how long it will take you to complete a given programming task.
C++ enjoys remarkable popularity across virtually all computing environments: personal computers, Unix workstations and mainframe computers. This is all the more remarkable when you consider the degree to which history weighs against a new programming language, no matter how good it is. The inertia implicit in the number of programs written in previous languages inevitably slows the acceptance of a new language. Added to this, there is always a tendency among most professional programmers to stick with what they know and in which they are expert and productive, rather than jump in at the deep end with something new and unfamiliar, in which it will take time to develop fluency Of course, the fact that C++ was built on C (which itself was the language of choice in many environments before the advent of C++) helped tremendously, but there's a great deal more to it than that. C++ provides you with a unique combination of advantages:
C++ is effective across an incredible range of applications. You can apply C++ to just about anything, from word processing to scientific applications, from operating system components to computer games.
C++ combines the facility for efficient procedural programming that it inherits from C, with a powerful object-oriented programming capability.
C++ provides extensive facilities in its standard library.
There are many commercial C++ libraries supporting a wide range of operating system environments and specialized applications. You will also find that just about any computer can be programmed in C++, so the language is pervasive across almost all computer platforms. This means that it should be possible to transfer a program written in C++ from one machine to another with relatively limited effort. Of course, if this is truly going to be a straightforward process, you need to have had in mind when you wrote the program that you intended to run it on a different machine.
Standardization is fundamental to transferring a program written for one type of computer to another. The establishment of a standard makes a consistent implementation of the language possible across a variety of machines. A full set of standard facilities across all conforming compilers means that you will always know exactly what you are going to get. Using ANSI standard C++ makes the migration of applications between different machines easier, and eases the problems of maintaining applications that run in more than one environment.
Of course, there are other things to consider. If your program is to be portable, you must not introduce facilities from non-standard libraries into your code, and you must take care to minimize the amount of dependency on the development machine that you build into the way the program works. To do otherwise may make migrating the code an uphill task.
Another benefit of ANSI standard C++ is that it standardizes what you need to learn in order to program in C++. The existence of the standard will itself force conformance over time, since it provides the only definitive reference for what a C++ compiler and library should provide. It removes the license to be 'flexible' that compiler writers have had in the absence of an agreed standard, so if you haven't already done so, insist on ANSI standard conformance when you buy your next C++ compiler....
Posted August 27, 2002
Explains everything thoroughly, awesome execution, if you find the Bitwise operators frustating, dont worry, and search for some tutorials on converting Decimal <-> Hex. Also the scientific windows calculator will automatically convert.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted September 22, 2001
If you are lost in the world of C++, or programming in general, purchase this book! Mr. Horton's detailed analysis of the language and the nature of programming is simple and easy to understand, yet complex and all-encompassing. When I began my 500 level university Object Oriented C++ course, I had never seen the language before. The class text provided was a joke, and the only way I survived was by reading and enjoying Horton's incredible book. This is NOT jus a reference, it's a lifesaver. If you want to feel comfortable writing your own successful programs in C++, this book is most definitely for you.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted February 13, 2001
Taking an introductory C++ at a local University. Found the required text to be extremely poor and hard to read. Bought Ivor's book and have been using it way more than the course text. It explains concepts by example, and very relavant examples at that. The topic of each chapter is broken down into smaller topics, each with it's own detailed explanation and most with their own example. The sample source code is plentyful too. This book is a keeper unlike the textbook for my class.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted August 27, 2000
This is a great book it explains everything in plain english and makes learning C++ fun and exciting. So if your trying to decide which book you should get to learn c++ this one is it.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.