4.4 Applications for Class CDataBase

Keep the following image in mind: a CDataBase object is a capsule around the complexities of managing two CPersonList objects and the files associated with their contents.

Because of this encapsulated design, you can use the class in any programming environment. The next two chapters will build a Microsoft Windows user interface around class CDataBase. But you could just as easily use the class in a character-based DOS application.

In fact, that's just what the CMDBOOK example program does. Because CMDBOOK so closely parallels the Phone Book program presented in the remaining chapters of the tutorial, CMDBOOK will not be explored in detail here. But a quick overview is in order.

CMDBOOK presents a command-line user interface. The user types in a command, such as “new” or “add”, and a command-line interpreter calls the appropriate function to handle that command. The command functions, in turn, call upon the services of a CDataBase object which is absolutely identical to the ones used in Phone Book.

You can study this different use of CDataBase in the code provided on the distribution disk. See file CMDBOOK.CPP in the MFC\SAMPLES\TUTORIAL directory.