Layering or Private Inheritance
Posted on 1998-04-06
I am currently developing a basic database application using CodeBase 6.3. I want to access all Codebase classes via my own classes in order to abstract(??) the majority of my code from CodeBase so that in the event that I change database engines down the track, switching over will be a relatively easy task.
Codebase uses a number of classes, one of which (Code4) is a class controlling data on a global basis, maintaining error codes and general determining the way data files will behave. Another class (Data4) controls the data files themselves. Data4 requires access to the Code4 class for certain functions however I do not want the Code4 member to be visible on a public basis.
Let's call my classes Class A (my equivalent of Code4) and Class B (my equivalent of Data4). I am unsure as to which of the following methods to use:
a) Private Inheritance: Class A derived privately from Code4 and declaring Class B as a friend to allow access to Code4 members.
b) Layering: Class A contains a private member variable Code4 and declaring Class B as a friend.
c) A better method I have missed.
Any advice would be greatly appreciated. Please reply via private email to firstname.lastname@example.org as well as to the newsgroup as my newsfeed is not the best.
Thanks in advance.