I modified the example a bit to make it a bit more clear. I use a single value to type T here for simplicity, but of course this not what happens in reality. But it is just to illustrate the idea.

Qt Code:
  1. /*Use of the classes in the main program*/
  2.  
  3. //Check for type of files and allocate based on type
  4. VolumeGeneral::type imageType;
  5.  
  6. //Determine the type based on input files
  7. ...
  8.  
  9. //Allocate with righ type
  10. VolumeGeneral* volume = 0;
  11.  
  12. if (imageType == typeU16)
  13. volume = new VolumeSpecified<unsigned short>();
  14.  
  15. else if (imageType == typeU8)
  16. volume = new VolumeSpecified<unsigned char>();
  17.  
  18. else
  19. break;
  20.  
  21. //Perform general operations
  22. volume->init();
  23. volume->doSomething();
  24.  
  25. //Perform type specific operations
  26. if (volume->getType() == VolumeGeneral::typeU16)
  27. {
  28. VolumeSpecified<unsigned short>* volumeS = dynamic_cast<VolumeSpecified<unsigned short>*>(volume);
  29. unsigned short testVariable = volumeS->getData();
  30. }
  31.  
  32. delete volume;
To copy to clipboard, switch view to plain text mode 

I don't see how I can do this without the extra class. If I only have my template class, I always need to specify the type, right? I can not use an object of type template class T without specifying T. So I need a base class which does not have any type to provide an interface.

What do you mean by using a 'base class pointer' when you say I don't need a wrapper? It seems like I need to list all methods in my abstract base class, since I need it as interface for my methods. If you talk about casting some base class pointer to the right template type, it seems this is something I always need to do, regardless whether I am exporting or importing data, or I am doing something where the type does not need to be visible.

Maybe I just need some example code on how to apply what you mean in my case, since it seems I am missing out on something ...