-
Create class at run time
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?
-
Shouldn't this be in the C++ forum?
-
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.
-
Thanks for replay.
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?