fork download
  1. #include <iostream>
  2.  
  3. struct clBaseSegment {};
  4.  
  5. template <class T>
  6. class structtemplatetest : public clBaseSegment, public T{
  7.  
  8. };
  9.  
  10. typedef struct irgendwas{
  11. char eins[5];
  12. char zwei[5];
  13. char drei[5];
  14. }irgendwas;
  15.  
  16. class tester : public structtemplatetest<irgendwas>{
  17. public:
  18. tester(irgendwas const& iw)
  19. {
  20. *static_cast<irgendwas*>(this) = iw;
  21. };
  22. };
  23.  
  24. int main()
  25. {
  26. irgendwas iw;
  27. iw.eins[0] = 'a';
  28. iw.zwei[0] = 'b';
  29. iw.drei[0] = 'c';
  30. tester tt(iw);
  31. std::cout << tt.eins[0] << " " << tt.zwei[0] << " " << tt.drei[0] << "\n";
  32. }
  33.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
a b c