S
- Steve -
I have a situtation where if a overloaded operator is used incorrectly I
need it to cout some info to the screen, end the function it was called in,
and continue on in main. How on earth do you do that?
The exact example can be found at http://planetevans.com/c under test 17,
18, and 19.
One of the specific examples is
test17()
{
cout << "17. Array declared with illegal array bounds: IntArray f(5,
2);" << endl << endl;
IntArray f(5, 2); //illegal becuase it is trying to define an
array with an index going from 5 to 2. The constructor is show below
for(int i = f.low(); i <= f.high(); ++i) //dont want this to run
f = i * 10; //dont want this to run
cout << f << endl; //dont want this to run
}
IntArray::IntArray(int low, int high)
{
arrayLow=low; //start of array index
arrayHigh=high; //end of array index
if(arrayHigh>=arrayLow)
array=new int[arrayHigh-arrayLow+1]; //create array memory
locations
else
cout << "Low Array Boundry Higher than High Array Boundry" << endl;
//now I need to end the function that this was called from
}
need it to cout some info to the screen, end the function it was called in,
and continue on in main. How on earth do you do that?
The exact example can be found at http://planetevans.com/c under test 17,
18, and 19.
One of the specific examples is
test17()
{
cout << "17. Array declared with illegal array bounds: IntArray f(5,
2);" << endl << endl;
IntArray f(5, 2); //illegal becuase it is trying to define an
array with an index going from 5 to 2. The constructor is show below
for(int i = f.low(); i <= f.high(); ++i) //dont want this to run
f = i * 10; //dont want this to run
cout << f << endl; //dont want this to run
}
IntArray::IntArray(int low, int high)
{
arrayLow=low; //start of array index
arrayHigh=high; //end of array index
if(arrayHigh>=arrayLow)
array=new int[arrayHigh-arrayLow+1]; //create array memory
locations
else
cout << "Low Array Boundry Higher than High Array Boundry" << endl;
//now I need to end the function that this was called from
}