The second method is actually using Exception handling:
#include <iostream>
using namespace std;
#include <stdexcept>
int main()
{
int [] arr1 = {10,69,30,12,11,34,56,78,35};
for ( int i=0; i<max; ++i )
{
try{ cout << "Data: " arr1[1] << endl;
}
catch (out_of_range &ex) {
cout << e.what() << endl; //the error message...
}
}
return 0;
};
This is more funny!
Good work for submitting to a professor teaching you Java
Last edited by evstevemd; Aug 26th, 2010 at 6:00 pm.
Reputation Points: 462
Solved Threads: 392
Senior Poster
Offline 3,681 posts
since Jun 2007