My question is about change/set dynamically a definition of a type checking a value of a variable which can change in run time like this simple example:
void changeMode(int mode)
{
if(mode == 1)
{
typedef MyType float;
}
else if(mode == 2)
{
typedef MyType double;
}
}
int main(int argc, char *argv[])
{
MyType (2);
MyType A = 3;
MyType B = 2;
MyType C = A + B;
return 0;
}
it's possible? It's a classic case of templates? it is possible to avoid using templates? My goal is centralize the type definition in order to be possible to switch at runtime, without the need to extend it to each class or use "templates" for each class/function that will use the given type.