All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the author.
This book was prepared with LaTeX and reproduced from camera-ready copy supplied by the author. The book is typeset using the Computer Modern fonts designed by Donald E. Knuth with various additional glyphs designed by the author and implemented using METAFONT.
Continue
Welcome to the online C++ tutorial! The purpose of this tutorial is to give a good understanding of the programming language C++ to any person that wants it.
So what is C++? Why are so many programs written in C++?
C++ is a third generation programming language. When computers were first invented, they were programmed with very simple, low-level commands. A programmer would design a program, then translate the program into a specific set of codes, known as machine language. These codes would be fed into a computer with switches, punch-cards, or primitive keypads. These programs were cumbersome to write, and very hard to debug. (Debugging is the act of removing mistakes in a program.) Machine code is considered the first generation of programming languages.
Continue
These tutorials were developed as part of a series of courses on C++ I taught at the University of California, Irvine, Washington University, St. Louis, and Vanderbilt University. I’m making these tutorials available on the Web for anyone who is interested in teaching or learning about C++. Other tutorials on C++ are available at http://www.cpp-home.com”. Discussions about C and C++ are available at http://www.cfanatic.com/
Continue
Chapter 3 is a fairly intense coverage of the C that’s used in C++, but if you’re just getting started with all this it may be a little too intense. To remedy this, the printed book contains a CD ROM training course that gently introduces you to the C syntax that you need to understand in order to take on C++ or Java. The CD is called Thinking in C: Foundations for Java & C++. Originally we sold this CD separately, but now it is only available bound into the printed versions of either Thinking in C++, 2nd edition or Thinking in Java, 2nd edition (the cost of the book including the CD is actually cheaper that the former cost of the CD alone). The CD was developed by MindView, Inc. and created by Chuck Allison. Chuck is a long-time member of the C++ Standards Committee, an editor on the C/C++ Users Journal, Author of the book C & C++ Code Capsules, and an experienced programmer and consultant. You can find out more about Chuck at http://www.freshsources.com or email him at cda@freshsources.com.
Continue
There aren’t that many books that teach C++. You can find good C++ reference books and technical books for advanced C++ programmers, but precious few books that actually teach programming in C++. Among them C++ In Action presents a unique approach–teaching the language from the perspective of a professional programmer.
Continue
This document tries to give the reader basic knowledge in compiling C and C++ programs on a Unix system. If you’ve no knowledge as to how to compile C programs under Unix (for instance, you did that until now on other operating systems), you’d better read this tutorial first, and then write a few programs before you try to get to gdb, makefiles or C libraries.
Continue
It helps if the standard annoys everyone in some way so everyone feels they are on the same playing field. The proposal here has evolved over many projects, many companies, and literally a total of many weeks spent arguing. It is no particular person’s style and is certainly open to local amendments.
Continue
Reading, MassachusettsMenlo Park, CaliforniaNew York
Don Mills, OntarioWokingham, EnglandAmsterdamBonnSydney
SingaporeTokyoMadridSan JuanParisSeoulMilanMexico CityTaipei
Continue
What follows is a set of rules, guidelines, and tips that we have found to be useful in making C++ code portable across many machines and compilers.
Continue
Programming is engineering, because the result (the program) is an artifact that works –it does something that is useful in its own right. Getting a program to work is hard, particularly when you’re a beginner, and you should feel proud of yourself when you get it working. That’s also why the majority of your grade on a programming assignment is based on just whether the program works at all. In my class, a working program will receive a minimum of about a 70–a passing score for a working program. The rest of the points come from the efficiency of the program (another aspect of the engineering task) and its style, which is important because programming is communication.
Continue