PDA

View Full Version : Create class at run time



muaed
04-10-2002, 02:10 PM
Is there someone who knows how to construct classes at run time from scratch, not at compile time?
With other words, we give a function some arguments; say name, functions member names, data member names, and the function will create the class from these arguments and return a pointer where the class is.
Is there any way to construct or create such a class at run time using either C or C++ or maybe mixing with assembly language?

jdinger
04-10-2002, 02:50 PM
Shouldn't this be in the C++ forum?

Shiro
04-10-2002, 03:39 PM
The question seems language independent, so I think it's valid being at the GD.

You could define a structure with a dynamically created array with function pointers and some pointers to arrays with variables. You can't fill in the functions from scratch.

muaed
04-11-2002, 08:13 AM
Thank you for replay.
I have tried to write the new class (which I created from scratch at run time) to a file and compile it at run time by invoking the compiler on that file to make an object file and put the new object in a library. But I do not know how to use the new created class from this library. How can I use this class at run time? How to calculate the relocation addresses if I load the class into the heap for example?