How to create a parameterized class with the parameter automatically got

In reply to chr_sue:

Maybe I didn’t express my intention clearly.
Actually I want to decide which kind of drv should be instantiated by the type of tr passed, instead of instantiating a fixed drv in advance