rgonzal@elbereth.rutgers.edu (Ralph Gonzalez) (08/30/90)
I'm trying to make my Think C 4.0 code fully upward compatible with C++ so
I can run things on some of the minicomputers around here. I've got
one problem which could mean some serious headaches.
In my Think C version of persistency (remember that
there are no automated constructor/destuctor functions available)
I was making use of the fact that in Think C a class name is itself a
void pointer. For example, if I create the class Persistent, then I can
define a member function returning a void pointer like this:
void *Persistent::get_class(void)
{
return Persistent;
}
Neat, eh? Now, in C++ this gives a syntax error. My question is: Is
there any way of passing class names like this in C++???????????
Thanks in advance!
-Ralph
Please reply via email to: rgonzal@chowder.rutgers.edu
patrickd@chinet.chi.il.us (Patrick Deupree) (08/30/90)
In article <Aug.29.15.16.53.1990.13694@elbereth.rutgers.edu> rgonzal@elbereth.rutgers.edu (Ralph Gonzalez) writes: > void *Persistent::get_class(void) > { > return Persistent; > } > >Neat, eh? Now, in C++ this gives a syntax error. My question is: Is >there any way of passing class names like this in C++??????????? The way things are done in Turbo C++ is that there is a file called "clstypes.h". Inside of this file is a table of definitions that looks something like: #define objectClass 0 #define containerClass objectClass+1 etc... This is the way that a class type is passed back. This class is passed back in a method (member function) called isA. There is also a member function called nameOf that will pass back a string representation of the class name. -- "What's in a name? That which we call a rose by any other name would smell as sweet." William Shakespeare Patrick Deupree -> patrickd@chinet.chi.il.us (708) 328-3800 (Please note there are both a patrick and a patrickd at this site)