I want to input the parameter (int) from keyboard and then pass it to template for creating an object. The template is
int lim;
cin>>lim;
mpa<lim,int,const char*> C;`
But it is required a constant expression. How to realize this action?
I want to input the parameter (int) from keyboard and then pass it to template for creating an object. The template is
int lim;
cin>>lim;
mpa<lim,int,const char*> C;`
But it is required a constant expression. How to realize this action?
It is impossible. Templates are instantiated during compile-time, and you want to change behavior in run-time. Alternatively if set of possible parameter values are know, you can mention them in switch / case or similar construct. Of course when using this technique one should be aware of code bloat - all instantiations of template will be compiled into binary, so this is not good way to do things at all