#include using namespace std; template /*vaikimisi väärtuseks 100 */ class Massiiv { T A[N]; public: T& operator[](int indeks) { if(indeks < 0 || indeks >= N){ cout << "vigane indeks\n" << endl; exit(1); } return A[indeks]; } }; struct mPunkt{ int x, y; }; int main() { Massiiv pm; Massiiv pm2; for(int i = 0; i < 10; i++) { pm[i].x = i; pm[i].y = i*i; } for(int j = 0; j < 10; j++) cout << j << ": " << pm[j].y << endl; pm2[3].x=1; cout << "Korras" << endl; pm2[6].x=1; cout << "Siia enam ei saa" << endl; } /* D:\kodu\0310>a 0: 0 1: 1 2: 4 3: 9 4: 16 5: 25 6: 36 7: 49 8: 64 9: 81 Korras vigane indeks */