previous up next print clean
Next: APPLICATIONS Up: Schwab & Urdaneta: Hilbert Previous: WHY OBJECT ORIENTATION?

WHY C++?

A variety of languages (including C and Fortran90) support object-oriented programming in the sense that they allow to bundle variables and methods into objects. A full-blooded object-oriented language (such as C++ or Java) additionally supports the combination of encapsulation, inheritance, and abstraction.

Encapsulation refers to the separation of the internal implementation of an object and its publicly available methods, the object's interface. For example, independent of whether an array of numbers is internally stored in a binary tree or a standard array, a public Add() method of such a class will perform the necessary steps to compute the element-wise addition. In general, objects interact exclusively through their public interface.

Inheritance enables a class to share another class's member variables and methods. Normally. this leads to classes that are enhanced, specialized versions of the parent class. Two classes that are derived from the same parent class have identical names and invocations for all inherited methods and variables[*].

Abstraction complements encapsulation and inheritance. Abstraction permits the programmer to declare an object's public methods without actually implementing them.

Abstraction allows us to enforce at compile time that future concrete implementations of a class implement the abstract class's methods. The vector class's public Add() method, which I mentioned above, is guaranteed to exist in any class derived from vector. Consequently, any object can trust that vectors have a method Add().

HCL essentially is a framework of such abstract classes. Programmers derive any application-specific class from a corresponding abstract HCL class and thereby inherit HCL's standard interface. The C++ compiler forces an application programmer to implement all the methods and variables that are inherited from an abstract base class. Finally, an object of the new class can interact with any other object of HCL through the inherited variables and methods. Only full-blooded object-oriented languages allow the inheritance of interfaces and enforce their consistency during compilation.


previous up next print clean
Next: APPLICATIONS Up: Schwab & Urdaneta: Hilbert Previous: WHY OBJECT ORIENTATION?
Stanford Exploration Project
11/11/1997