GNU C++ Programming with Linux


Tom Swan's book "Gnu C++ for Linux" is an excellent source for learning to do C++ programming on a Linux system, even if you already know a good bit about C++ programming, and especially if you don't. The book comes with a large number of well-written example code files on an enclosed CD, and each one of these code files contains a header such as in the following example:

// welcome.cpp -- A simple C++ program
// Time-stamp: <2000-03-28 22:48:08 parrish>
// To compile:
//   g++ -o welcome welcome.cpp
// To run:
//   ./welcome
// Copyright (c) 1999 by Tom Swan. All rights reserved.


int main()
  cout << "Welcome to GNU C++ for Linux programming!" << endl;
  return 0;

These well-designed headers make it easy and comfortable to churn through large numbers of code files in an a single efficient study session. Load all of Swan's code files into a local directory and open the kfm file browser on the directory corresponding to the chapter you want to study (Swan's book has 30 chapters of GOOD STUFF). Clicking on a file's entry in kfm causes the file to be opened in a kedit window. Read, absorb, and admire the enclosed code, then use your mouse to copy the compilation command from the header and paste it to a command prompt. Hit Enter to compile the file. Similarly, copy the command to run the executable from the header, paste it to a command prompt and hit Enter to view the result of running the executable. Once you get into the swing of it, the arrow keys become very useful for scrolling back through your history to recover and reissue previous commands with little or no typing. With a few minutes practice, one learns to arrange the kfm, kedit, and konsole windows so that this whole process requires an absolute minimum of mousing and typing, and a maximum of study efficiency. Many of us prefer to use the gcc compiler from within emacs so that the results of a session can be saved and edited. Inside emacs, the arrow keys take on cursor-moving functions, but Cntl-arrow recovers the history function.

Standard Template Library

The Standard Template Library, STL, is a C++ library of container classes, algorithms, and iterators implementing such ADT's as sets, lists, vectors, and hash tables. Your own projects can make use of these standard templates for implementing these useful constructs, rather than reinventing implementations over and over again. For further specific information, see the STL API.