Containment Delegation  «Prev  Next»
Lesson 2 Integrating objects: C++ classes
ObjectiveExplain how C++ classes integrate at the source code.

Integrating Objects: C++ Classes

A software component is an independent module that provides services through interfaces."
Given this definition, what makes a software component different from a C++ class or any other object-based unit of method and data encapsulation? To answer this, let us look at an integration scenario involving developers at two companies:
  1. ClassLibraries Inc. (CLI) and
  2. AppBuilders Company (ABC).

ABC has purchased a class library developed at CLI. The class library is provided as a set of header files that define classes, an import library to link to, and a DLL (dynamic link library) called CLI.dll that contains version v1.31 of the CLI library.
Elvis is a developer at ABC making use of class CLILookup. To use class CLILookup, Elvis includes the appropriate header files and links with required libraries, and writes the following code:

void FindRec(...) {
   CLILookup cli;

   cli.Init();
   ...
}

CLI ships new version of its C++ Class Library

After Elvis gets everything working, CLI ships a new version of its C++ class library, v1.32. The only change is the addition of a couple of private variables and member functions in class CLILookup. Even though no changes have been made to any accessible/public members, Elvis must rebuild his code. Why?
C++-based code integration requires that a programmer using a C++ class have access to a header file that describes the internal in-memory layout of the class. If Elvis did not rebuild his code, his in-memory layout of class CLILookup would differ from the memory image of the actual C++ being used. Using mismatched versions would probably result in crashes and/or unpredictable behavior. This lesson demonstrates that C++ classes are integrated at the source code. In the next lesson, we will present a similar scenario using a COM component.