- Table of Contents
- Copyright
- About the Lead Authors
- About the Contributing Authors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- I. Red Hat Linux Installation and User Services
- Chapter 1. Introduction to Red Hat Linux
- Chapter 2. Installation of Your Red Hat System
- Chapter 3. LILO and Other Boot Managers
- Chapter 4. Configuring the X Window System, Version 11
- Chapter 5. Window Managers
- Chapter 6. Connecting to the Internet
- Chapter 7. IRC, ICQ, and Chat Clients
- Chapter 8. Using Multimedia and Graphics Clients
- II. Configuring Services
- Chapter 9. System Startup and Shutdown
- Chapter 10. SMTP and Protocols
- Chapter 11. FTP
- Chapter 12. Apache Server
- Chapter 13. Internet News
- Chapter 14. Domain Name Service and Dynamic Host Configuration Protocol
- Chapter 15. NIS: Network Information Service
- Chapter 16. NFS: Network Filesystem
- Chapter 17. Samba
- III. System Administration and Management
- Chapter 18. Linux Filesystems, Disks, and Other Devices
- Chapter 19. Printing with Linux
- Chapter 20. TCP/IP Network Management
- Chapter 21. Linux System Administration
- Chapter 22. Backup and Restore
- Chapter 23. System Security
- IV. Red Hat Development and Productivity
- Chapter 24. Linux C/C++ Programming Tools
- Chapter 25. Shell Scripting
- Chapter 26. Automating Tasks
- Chapter 27. Configuring and Building Kernels
- Chapter 28. Emulators, Tools, and Window Clients
- V. Appendixes
- A. The Linux Documentation Project
- B. Top Linux Commands and Utilities
- C. The GNU General Public License
- D. Red Hat Linux RPM Package Listings
Elements of the C++ Language
If C is the language most associated with UNIX, C++ is the language that underlies most graphical user interfaces available today.
C++ was originally developed by Dr. Bjarne Stroustrup at the Computer Science Research Center of AT&T's Bell Laboratories (Murray Hill, NJ), also the source of UNIX itself. Dr. Stroustrup's original goal was an object-oriented simulation language. The availability of C compilers for many hardware architectures convinced him to design the language as an extension of C, allowing a preprocessor to translate C++ programs into C for compilation.
After the C language was standardized by a joint committee of the American National Standards Institute and the International Standards Organization in 1989, a new joint committee began the effort to formalize C++ as well. This effort has produced several new features and has significantly refined the interpretation of other language features.
Programming in C++: Basic Concepts
C++ is an object-oriented extension to C. Because C++ is a superset of C, C++ compilers will compile C programs correctly, and it is possible to write non–object-oriented code in C++.
The distinction between an object-oriented language and a procedural one can be subtle and hard to grasp, especially with regard to C++, which retains all of C's characteristics and concepts. One way to describe the difference is to say that when programmers code in a procedural language, they specify actions that process the data, whereas when they write object-oriented code, they create data objects that can be requested to perform actions on or with regard to themselves.
Thus, a C function receives one or more values as input, transforms or acts on them in some way, and returns a result. If the values that are passed include pointers, the contents of data variables can be modified by the function. As the standard library routines show, it is likely that the code calling a function will not know, and will not need to know, what steps the function takes when it is invoked. However, such matters as the datatype of the input parameters and the result code are specified when the function is defined and remain invariable throughout program execution.
Functions are associated with C++ objects as well. But the actions performed when an object's function is invoked can automatically differ, perhaps substantially, depending on the specific type of the data structure with which it is associated. This is known as overloading function names. Overloading is related to a second characteristic of C++—the fact that functions can be defined as belonging to C++ data structures, an aspect of the wider language feature known as encapsulation.
In addition to overloading and encapsulation, object-oriented languages allow programmers to define new abstract data types (including associated functions) and then derive subsequent data types from them. The notion of a new class of data objects, in addition to the built-in classes such as integer, floating-point number, and character, goes beyond the familiar capability to define complex data objects in C. Just as a C data structure that includes an integer element inherits the properties and functions applicable to integers, a C++ class that is derived from another class inherits the parent class's functions and properties. When a specific variable or structure (instance) of that class's type is defined, the class (parent or child) is said to be instantiated.
File Naming
Most C programs will compile with a C++ compiler if you follow strict ANSI rules. For example, you can compile the standard hello.c program (everyone's first program) with the GNU C++ compiler. Typically, you will name the file something like hello.cc, hello.C, hello.c++, or hello.cxx. The GNU C++ compiler will accept any of these names.
Project Management Tools | Next Section

Account Sign In
View your cart