An Overview of C++

Goals of C++

  • To make programming in C more pleasant, more productive, and less error-prone.
  • To be as upward compatible with ANSI C as possible (but no more so).
  • To support data abstraction, information hiding, and encapsulation.
  • To support object-oriented programming.
  • To provide performance comparable to C.
  • To be widely available, and widely accepted.

Evolution of C++

  • Developed by Bjarne Stroustrup at AT&T Bell Labs in the early 1980s.  
  • An ANSI/ISO committee is working on C++ standardization.
  • Influences:  C, Simula 67, Algol 68
  • First version in 1980: “C with Classes”
    • Classes: An Abstract Data Type Facility for the C Language, ACM SIGPLAN Notices, 1982
    • Adding Classes to C: An Exercise in Language Evolution, Software — Practice and Experience, 1983
  • Renamed C++ in 1983/84
  • Educational Release in 1983
  • General Releases 1985, 1986, 1987, 1988, 1989, 1990, …
  • ANSI/ISO C++ Standard finalized in 1998.

C++ Resources

  • The C++ Programming Language, (First Edition) Bjarne Stroustrup, Addison-Wesley, 1986 (was the ‘C++ Bible’, but is now completely out of date)
  • USENIX C++ Workshops in Sante Fe, New Mexico (1987) and Denver, Colorado (1988) (Proceedings available from USENIX Association)
  • The Annotated C++ Reference Manual (ARM), Margaret Ellis and Bjarne Stroustrup, Addison-Wesley, 1990  (The new ‘C++ Bible’ reference, and the base for the ANSI/ISO C++ standards effort)
  • The C++ Programming Language, (Third Edition) Bjarne Stroustrup, Addison-Wesley, 1997. This is really the new ‘C++ Bible’, and is a major rewrite of the Second Edition (which in turn considerably augmented the First Edition).
  • The Design and Evolution of C++, Bjarne Stroustrup, Addison-Wesley, 1994. 
    Some interesting insights into why the language is the way it is.
  • There are now lots of books on C++, some good, some bad, some terrible…

C++ Penetration

  • Probably the fastest-growing computer language (until Java came along).
  • Installed on thousands of computers from micro to mainframe, across the entire world.
  • Use of C++ has burgeoned
    (Stroustrup estimated at one point that, over a considerable period of time, the number of C++ users was doubling every 4 to 6 months!)
  • Used in wide variety of applications:
    • C++ compiler, debugger
    • Financial Trading systems
    • Switching systems
    • Simulations
    • Graphics/Windows
    • etc., etc.

C++ Characterization

  • Roots same as those of C (Bell Labs)
    • Similar ‘pragmatic’ approach (as opposed to ‘theoretical’)
  • Decidedly a hybrid Object-Oriented language
  • Supports Object-Oriented programming, but does not require it
  • Does not penalize you (in terms of performance) if you don’t use a feature.
  • C++ is a very large, complex language (at least as much as Ada).
  • Some people, especially from the ‘pure O-O’ camp, criticize it for its complexity and ‘warts’.
    • There was a lot of ‘C++ bashing’ at the 1990 OOPSLA conference.    
  • Bell Labs was reputed to use C++ as a ‘better lint’
  • C++ use has been growing by leaps and bounds, although not all its adherents use it for O-O.
  • At one point, it probably had no significant competition for being the predominant O-O programming language.  This has changed with the advent of Java.

C++ Implementations

  • AT&T translator (cfront):
    • A “front end” for a C compiler.
    • Written by Stroustrup and others at Bell Labs.
    • Generates C source code, not object code directly (this was key to C++’s initial wide acceptance and rapid growth)
    • Written in C++ with a bootstrap version in C
  • True compilers:
    • Microsoft Visual C++
    • Borland C++Builder
    • gcc (GNU C++ from the Free Software Foundation) for a wide variety of platforms.
    • Sun C++ for Sun   
    • Lots of others, many from hardware vendors (HP, IBM, etc.)…

Note: The above list needs to be updated…

C++ Features

  • C++ is more than just ‘an enhanced C’
  • Features can be classified as:
    • Small Enhancements
    • Large Enhancements
  • Distinctions between ‘small’ and ‘large’ not always clear-cut.
  • All of the ‘Small Enhancements’ and some of the ‘Large Enhancements’  can be used without touching Object-Oriented programming.
  • To make optimal use of C++, however, it really pays to try to use a different  ‘O-O mindset’.
  • Small Enhancements
    • Line-style comments
    • struct/union/enum tags become true type names
    • Declaration placement
    • Scope operator
    • const specifier (stricter than ANSI C)
    • Anonymous union
    • Explicit (function-like) type conversion
    • Function prototypes (stricter than ANSI C)
    • Overloading of function names
    • Default values for function parameters
    • Functions with unspecified number of parameters (stricter than ANSI C)
    • Reference parameters in functions
    • inline specifier
    • new and delete operators 
    • Pointers to void and functions returning void (stricter than ANSI C)
  • Large Enhancements
    • Stronger typing, with the necessary extensions for object-oriented programming       
    • The class construct, and class member encapsulation
    • Constructors and destructors (automatically invoked; guaranteed to be invoked on creation and destruction of an object)
    • Overloading of operators and functions
    • References (general use)
    • friends of a class
    • Member class objects
    • const member functions
    • static members
    • Derived classes (including multiple derivation)
    • virtual functions
    • Virtual base classes
    • Exceptions
    • Templates

The Five Levels of C++ Mastery

  • It has been said by a large organization using C++ that there are five levels a typical C user may go through when learning C++:
    • Level 0: can be described as typical C and usually takes days to learn.
    • Level 1: can be described as better C (C++’s stronger type checking) and usually takes a week or so to learn.
    • Level 2: can be described as advanced C (inlining) and usually takes a month to learn.
    • Level 3: can be described as abstract data type (defining classes) and usually takes up to six months to learn.
    • Level 4: can be described as object-oriented programming paradign (use of inheritance and polymorphism) and usually takes up to a year to learn.  This is also called an object-oriented design level (OO analysis, OO design and use of an OO database).
  • At the end of level 4, C programmers are thinking in the object-oriented paradigm and begin to rethink their programming design methodology.  
  • This stuff takes time!
Index