donald@cae780.UUCP (Donald Maffly) (11/08/90)
I am wondering if anyone could give me a quick answer to an interesting C++ problem. I have pre-exiting code with a class structure. I'd like to extend it (by adding new members (iv's and methods) without changing the existing files. Motivation for doing this would be to assure that the original implementation could be compiled, loaded and run indepedently of the extended implementation. For the sake of illustration, let's say the we are doing a tree implementation with a complicated class hiearchy of Node types. The original interface is contained in "node1.hxx" and its implementation in "node1.cxx". I'd like to be able to extend the implemenation in separate files "node2.hxx" and "node2.cxx". In this manner, node2 would be dependent on node1, but node1 would NOT be dependent on node2. I realize that the conventional way of achieving this extension would be to define a new node type "node2" and derive it from the original "node1". But this solution has the major short-coming of losing the funtionality of all of the sub-classes (derived classes) of node1 in the original implementation. If I were to instead inherit from all of the sub-classes of node1, that could amount to alot of work, and it would prevent me from defining a new class node2 in which to place shared functionality. So I am wondering if there exists a simple way of extending a class definition in a new file without using inheritance and without disturbing the original implementation (.cxx) and interface (.hxx). If such a mechanism exists in C++, it would add layer of functionality around a pre-existing class such that the originally defined sub-classes of the pre-existing class could inherit it (i.e. the new layer of functionality). Donald Maffly