fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename Type>
  6. class Vector {
  7. public:
  8. Type& operator[](int i) {
  9. return data[i];
  10. }
  11. public:
  12. Type &x = data[0], &y = data[1], &z = data[2];
  13.  
  14. private:
  15. Type data[3];
  16. };
  17.  
  18. int main(int argc, char * argv[])
  19. {
  20. Vector<int> v;
  21. v.x = 1; v.y = 2; v.z = 3;
  22. cout << v[0] << " " << v[1] << " " << v[2] << endl;
  23. }
  24.  
Success #stdin #stdout 0s 5668KB
stdin
Standard input is empty
stdout
1  2  3