fork download
  1. #include <iostream>
  2.  
  3. struct atama_
  4. {
  5. int operator ()(){ return 1; }
  6. };
  7.  
  8. struct mune_
  9. {
  10. char const * operator ()(int i){ return "tekitou"; }
  11. };
  12.  
  13. struct robo_ {
  14. atama_ a;
  15. mune_ m;
  16. char const * operator ()(){ return m(a()); }
  17. };
  18.  
  19. struct gattai {};
  20. struct g_a
  21. {
  22. atama_ a;
  23. };
  24.  
  25. g_a operator +(gattai const &g, atama_ const &a)
  26. {
  27. return {a};
  28. }
  29.  
  30. robo_ operator +(g_a const &g, mune_ const &m)
  31. {
  32. return {g.a, m};
  33. }
  34.  
  35. int main()
  36. {
  37. using namespace std;
  38.  
  39. auto atama = atama_();
  40. auto mune = mune_();
  41. auto robo = gattai() + atama + mune;
  42. cout << robo() << endl;
  43. }
  44.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
tekitou