#include using namespace std; //Suuruskontrolliga massiiv template class Massiiv { static const int suurus=100; T A[suurus]; public: T& operator[](int indeks) { if(indeks < 0 || indeks >= suurus){ cout << "vigane indeks\n" << endl; exit(1); //automaatne katkestus } return A[indeks]; } }; struct mPunkt{ int x, y; }; int main() { Massiiv pm; 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; } /* D:\kodu\0309\oma>a 0: 0 1: 1 2: 4 3: 9 4: 16 5: 25 6: 36 7: 49 8: 64 9: 81 */