#include using namespace std; struct array_of_4_ints { int v[4]; int access(int index) { if (index >=0 && index < 4) return v[index]; cout << "error in index\n"; exit(1); } void set(int index, int value) { if (index >= 0 && index < 4) v[index] = value; else { cout << "error in index\n"; exit(1); } } }; int main() { int a = 101, b = 202, c = 303; array_of_4_ints d; d.set(0, 1111); d.set(1, 2222); d.set(2, 3333); d.set(3, 4444); int e = 404, f = 505, g = 606; for (int i = 0; i < 10; i += 1) cout << d.access(i) << "\n"; d.set(f/101, 9999); cout << "a == " << a << "\n"; cout << "b == " << b << "\n"; cout << "c == " << c << "\n"; cout << "e == " << e << "\n"; cout << "f == " << f << "\n"; cout << "g == " << g << "\n"; }