I'm trying to build an object which is of a type which depends on input parameters. E.g. my object is called 'process' and at runtime an integer between 2 and 5 (inclusive) is entered and something a bit like this would happen:
if (input == 2) TwoJ process;
if (input == 3) ThreeJ process;
if (input == 4) FourJ process;
if (input == 5) FiveJ process;
Obviously the above will not work because the object goes out of scope immediately. Is there a way to implement this nicely? Cheers