JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
8 months ago115 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;
}

⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.

← Back to timeline