Overview:
OBJECT-ORIENTED PROGRAMMING AND
C++
(Note: This set of notes was compiled from several separate documents, and points may be repeated.)
- New libraries
- End-of-line comments
- Typing and scope
- References and pointers
- C++ I/O
- Allocation
- References in functions
- Overloading
- Contrast between imperative languages (C, Pascal) and object-oriented languages.
- Key concepts and terminology for object-oriented languages.
- Analogous to types for imperative languages, and the key organizational feature of object-oriented languages.
The following table shows the correspondence between features of C and of object-oriented languages.
There are two or three other significant aspects to object-orientation. The first is "hierarchy" or "inheritance"; the
second is "protection".
- C++ class definition and use syntax.
- Constructors and destructors
- Methods
- Syntax and semantics for inheritance in C++.
- A few complications.
Review
- Object-oriented programming is distinguished by having
- explicit visibility (of variables and functions) controlled through thedeclarations of types and variables, rather
than through nesting of functions.
- inheritance
- override.
- C++ is not a pure object-oriented programming language, but rather adds object-oriented features to ANSI C.
- In particular, almost any legal C program will be a legal C++ program, if not in the spirit of object-oriented
programming.
- However, system interfaces may be different. The built-in functions, and their organization into
#include files, the effect of other #-commands, and of other system utilities, may differ.
- Explicit memory management is handled either by object-oriented features (see constructors and destructors
below), or by the new and delete commands (rather than malloc, dealloc, and
company.
- Most of the object-orientation shows up in C++ in constructs and use of structured variables.
Other concepts [to be added]
- Some other ideas: abstract classes (base classes with no instances themselves); virtual functions (which allows
a certain degree of polymorphism by allowing derived classes implicitly in prototypes.
- Files in C++.
- Management of large files: makefiles and projects .