fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class DynamicInteger;
  5.  
  6. template <int L>
  7. class StaticInteger {
  8. public:
  9. StaticInteger(int x) {}//bla bla
  10. template <int M>
  11. StaticInteger<L> operator+(StaticInteger<M> x) {}
  12. //operator DynamicInteger () const;
  13. private:
  14. //bla bla
  15. };
  16.  
  17. class DynamicInteger {
  18. public:
  19. template <int M>
  20. DynamicInteger (StaticInteger<M> m ) { cout<<"construct Dynamic from "<< M<<endl; }
  21. DynamicInteger operator+(DynamicInteger x) {}
  22. private:
  23. };
  24.  
  25. //template <int M>
  26. //StaticInteger<M>::operator DynamicInteger () const { return DynamicInteger(*this);}
  27.  
  28. int main() {
  29.  
  30. StaticInteger<16> a = 10, b=20;
  31. StaticInteger<16> c = a+b;
  32. DynamicInteger x = a;
  33. DynamicInteger z = x + b;
  34. return 0;
  35. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
construct Dynamic from 16
construct Dynamic from 16