[comp.lang.c++] ISA function implementation

mgardi@watserv1.waterloo.edu (Mutual Life) (01/12/90)

I am curious how people have implemented the idea similar to 
'SUPER' in Smalltalk.
We would like to do something like to following:

              Asset
             /    \
        Liquid     Non-Liquid 
        /   \
     GIC    STOCK

Now, for reporting purposes, we would like to pass a container of
ASSETS to the report generator. For a particular report, it would like
to group all Liquid Assets together. Once the assets are put into a 
container, they lose their identity (they are all (asset *).
Thus we would like to use a function like the Smalltalk ISA function.
It would work something like this:

for all assets in container
  if (asset->ISA('Liquid'))
	do something.

The isa() code would be something like:

if (thisID == 'GIC')
	return TRUE;
else
        super:isa(thisID);

We do NOT want to hardcode a base classes name in every derived classes
isa method. ie. In C++, we can go   Liquid:isa(thisID);

In general, we would like to get at a base classes (and perhaps its base
class) methods without hard coding a dependancy tree.

Hope this makes sense.
Any help would be appreciated.
p.

Peter DeVries
Mutual Life of Canada
c/o mgardi@watdcsu
(519) 888-2290
(416) 972-0594