Our first task to make a WhereIs object act like a pointer to a ThisIsA object, but with the proper exposure of the actual payload type. This can be accomplished by the use class templates.
Our first attempt is illustrated by listing 1.
Listing 1: | WhereIs.01 |
We define ThisIsA as a member class of WhereIs<T>. This is because we will be using WhereIs<T> more often. In fact, the member class ThisIsA is private, which means we do not have explicit access to the class! This implies that we cannot explicitly create objects of the type WhereIs<T>::ThisIsA.
All operations are WhereIs centric. Here is a short explanation of the methods of WhereIs:
The test subroutine illustrates how some of the methods are used.
This first trial is neat, but all it does is to introduce a lot of extra typing with no real benefit.