fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Fruit {
  5. float energy;
  6. float taste;
  7. };
  8.  
  9. template<typename T>
  10. class Value {
  11. public:
  12. T val;
  13. T* operator->() { return &val; }
  14. };
  15.  
  16. int main() {
  17. Value<Fruit> apple;
  18.  
  19. apple->energy = 0.5f;
  20. cout << apple->energy << endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
0.5