fork download
  1. #include <iostream>
  2.  
  3. template<class CRTP> class A0
  4. {
  5. public:
  6. void myfunction1();
  7. protected:
  8. ~A0() {}
  9. public:
  10. double mymember;
  11. };
  12.  
  13. template<class CRTP> class B0 : public A0<CRTP>
  14. {
  15. public:
  16. void myfunction2();
  17. protected:
  18. ~B0() {}
  19. };
  20.  
  21. template<class CRTP> class C1 : public B0<CRTP>
  22. {
  23. public:
  24. void myfunction3();
  25. protected:
  26. ~C1() {}
  27. };
  28.  
  29. template<class CRTP> class C2 : public B0<CRTP>
  30. {
  31. public:
  32. void myfunction4();
  33. protected:
  34. ~C2() {}
  35. };
  36.  
  37. class D1 : public C1<D1>, public C2<D1>
  38. {
  39. public:
  40. void myfunction5();
  41. };
  42.  
  43. using namespace std;
  44.  
  45. int main() {
  46. D1 d;
  47. d.C1<D1>::mymember = 5;
  48. d.C2<D1>::mymember = 27;
  49. cout << d.C1<D1>::mymember << ", " << d.C2<D1>::mymember << endl;
  50. return 0;
  51. }
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
5, 27