#include <iostream>
using namespace std;

struct foo {
	int x;
	int y;
	int z;
};

int& operator [](foo& lhs, const std::size_t rhs) {
	switch(rhs) {
	case 0U:
	    return lhs.x;
	case 1U:
		return lhs.y;
	case 2U:
		return lhs.z;
	default:
		return *(&(lhs.z) + rhs - 2U);
	}
}

int main() {
	foo my_foo{};
	
	cout << foo[0U] << endl;
}