can you give me an example? thanks!
can you give me an example? thanks!
Could you be more specific? What exactly are you asking?
Brendan
Draco dormiens nunquam titallandus.
Console Graphics Library: http://www.geocities.com/steve_alberto/cgl.html
How to add data and function as the program is running
Do you mean like...be able to accept user input, but in the meantime do something else? If so, you use the kbhit() function...it's in, er..."conio.h" if you have it. It would work like so.
I hope that helps. If that wasn't what you were asking...then, er...hope it helps anywaysCode:for(;;) { if(kbhit()) break; cout << '.'; }
Brendan
Draco dormiens nunquam titallandus.
Console Graphics Library: http://www.geocities.com/steve_alberto/cgl.html
thank you for your reply,but you didn't understand my problem.
the data is a member data of the class ,and the function is a member function of the class. i want to add them to an object when the program is running .
sorry,my english is poor
who can help me!!
Maybe you should look into shared libraries, that is, DLL for Windows and .so for Linux (probably for Unix as well).
That's the best I can think with what you've said.
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
could you try focusing and making a coherent paragraph on the exact details of what you want?
Uhm... whats so complicated about his question? He want's to add functions and data (variables) to a class or an instance of that class at runtime. imho.
That said, unfortunatly I have no clue how to do it or if it is even possible in C++. I have a more or less similar problem right now, but I guess I better open another thread for it.
Last edited by darksaidin; 08-23-2003 at 02:34 PM.
maybe you want to use virtual function tables (code your own) and dito for variables...
something like:
its late in night so excuse the pseudo code and no real example...Code:map<string, function_type> function_list; addFunction(function_pointer, function_name){ function_list[function_name] = function_pointer } callFunction(function_name){ (function_type&)function_list[function_name]() }
same goes for variables, but in the case of variables you ave to have a type that can be any value, so i propose some kind of templated type... i think the boost lib have an all purpose data type... oh.. by the way, same thing goes for functions and parameters/return value.
its quite a complicated system you are planing on implementing, so maybe you should look up some scripting lib like lua and a loot others?