Dynamically create this idea is also a long time. I know that I can do this with macro, but I have been
There is no truly do it. Today, I am interested, I simply do it. . .
The final result can probably be the following:
Class TT
{public:
Tt () {a = 1;}
Int a;
Class P: Public TT {public: PUBLIC:
P () = 2;
}
RegisterClass (TT, 12)
RegisterClass (P, 13)
Void main () {tt * t = (tt *) zfactory :: getInstance () -> CREATECLASS (12);
Tt * p = (tt *) zfactory :: getInstance () -> CREATECLASS (13);
Cout <
a
Cout <
a
}
Output 1 2
It should be correct.
The only thing to do is to write two macros. . . . Still very convenient
This can only be dynamically generated here according to the int type. I'm trying to make it into a template.
But I have encountered some setbacks, and it seems that I can't do so beautiful, I need to add new parameters in the macro,
For example, specify parameter type int, Double