I'd like to start off by thanking the many of you who provided me info about the ARM. I now have Stroustrup 2nd edition and it's just what I needed. The book I originally had was Stroustrup 1st edition, not a book by Dijikstra. My apologies for the mass confusion this caused!!
Down to business. I need some assistance designing my class hierarchies for the following situation:
I am writing device drivers for external memory devices. I currently have to support two types devices (say A and B), but that number could grow. The functions each device must support are common, but the implementations used to provide them are quite different for each. The type T below can be a char xor a short. The following template class defines these core functions:
template <class T> class core_functions
{
public:
T Read cell(int address);
void Write_cell(int address, T data);
};
I want to design the hierarchy so I can easily add device C, D, E etc. Here's the catch. How can I do this so that the application programs only need to see the core_function class declaration; not the derived class declarations for A or B. I need to enhance the core_functions class so that the user can call a core_functions function, and it will be directed to the implementation in the proper derived class (A or B).
If I derive A or B from core_functions, then the application must declare objects of type A or B, thus they will need to have access to the derived class declarations.
If I use A or B as a base class, then there have to be different derived core_functions classes; one derived from A, the other from B. This prevents the user from seeing the declarations for A and B, but doesn't seem very elegant. I want to have only 1 core_functions class.
I tried making the core_functions functions virtual. That let me call core_functions functions, redirecting them to the implementations in A and B. This didn't prevent the application from needing the A and B class declarations,