|
|
|
|
|
|
|
checkInTime.Write();
someObject.Write();
Write(n); |
|
|
|
|
|
|
|
|
then the C++ compiler has no trouble distinguishing among the three Write functions. In the first two function calls, the dot notation denotes class member selection. The first statement invokes the Write function of the TimeType class, and the second statement invokes the Write function of the SomeClass class. The final statement does not use dot notation, so the compiler knows that the function being called is the global Write function. |
|
|
|
|
|
|
|
|
Conceptually, a class object has an invisible wall around it. This wall, called the abstraction barrier, protects private data and functions from being accessed by client code. The barrier also prohibits the class object from directly accessing data and functions outside the object. This barrier is a critical characteristic of classes and abstract data types. |
|
|
|
|
|
|
|
|
For a class object to share information with the outside world (that is, with clients), there must be a gap in the abstraction barrier. This gap is the public interfacethe class members declared to be public. The only way that a client can manipulate the internals of the class object is indirectly through the operations in the public interface. Engineers have a similar concept called a black box. A black box is a module or device whose inner workings are hidden from view. The user of the black box depends only on the written specification of what it does, not on how it does it. The user connects wires to the interface and assumes that the module works correctly by satisfying the specification (see Figure 15-4). |
|
|
|
|
|
|
|
|
In software design, the black box concept is referred to as information hiding. Information hiding protects the user of a class from having to know all the details of its implementation. Information hiding also assures the |
|
|
|
|
|