Skip to main content
JustPaste
HomeAboutDonateContactTerms of UsePrivacy Policy

© 2026 Just Paste. All rights reserved.

Made with ❤️ by TakiDev

Untitled Page | JustPaste.app
Publish 4 months ago102 views

#include <iostream>

using namespace std;

#include <process.h>

const int LIMIT = 100;

class safearray{

int arr[LIMIT];

public:

int& operator [](int n){

if(n<0 || n>= LIMIT){

cout<<"\nIndex out of bounds: ";

exit(1);

}

return arr[n];

}

};

int main(){

safearray sa1;

int j;

for(j=0;j<LIMIT;j++){

sa1[j] = j*10;

}

for(j=0;j<LIMIT;j++){

int t=sa1[j];

cout<<"Element " << j << "is" <<t<<endl;

}

return 0;

}