fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Vector3D {
  5. int v[3];
  6. int& x() { return v[0]; }
  7. int& y() { return v[1]; }
  8. int& z() { return v[2]; }
  9. };
  10.  
  11. int main() {
  12. Vector3D coord;
  13. coord.v[0] = 5;
  14. cout << coord.x() << endl;
  15. coord.y() = 10;
  16. cout << coord.v[1] << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
5
10