help with automatic code generation

J

JoshforRefugee

heard that we can do automatic code generation using macros, but not
sure how can I pursue this. Here is my problem.

In my env, I have class A,B and C. All of them has constructors, and
few common methods, like reset, and execute.

now my env(main) class actually is where I am creating this objects.
in .h
A myA;
B myB;
C myC;

and later I am calling methods in my .C file
myA.reset();
myB.reset();
myC.reset();
myA.execute();
.....
myC.execute();

now let say if I add Class D, I have to modify my env.h and env.C. And
I am trying to prevent that.
one way i was thinking of doing this, is to write macros:
so I can do:
REGISTER_OBJECT("A","myA");
REGISTER_RESET("A","myA",reset);
REGISTER_EXECUTE("A", "myA", execute)
.............

May be using macros might be one way to do this. I am really confuse
how I can I write this macros. Please guide me.

Thank you,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top