I have a TClass * for a class and I want an instance of this class. In previous versions, this was done using TClass::New() with a default constructor, and it was fine.
However, now (for supported classes) I want to use an argument in the constructor (which for this purpose happens to be a single string), generated at run-time.
Is there any way to do this? I initially looked at trying to defining my own StringIOCtor class and using:
With this, however, I don’t see how I actually construct an instance of the StringIOCtor class that should be used - is the type just being used as a flag to indicate a different constructor should be used, without instantiating the object?
I guess “ugly” is a matter of taste, but glad the suggestion works for you De facto, the interpreter allows you to have a simple and universal plugin factory.
Another solution could consist in creating a factory yourself, e.g. implementing factory methods in your libraries returning fresh class instances.