The primary issue is my exception within my test function continuously prints the exception, but ignores the rest of the functions within the try {}block and prints the exception, no matter how i change the conditions.
So in a separate Header file, I've created an exception class DataSizeFullException. This will not all although me to add a value to an array once the size is greater than capacity.
#ifndef DATASIZEFULLEXCEPTION_H_INCLUDED
#define DATASIZEFULLEXCEPTION_H_INCLUDED
class DataSizeFullException{
public:
void print(){
cerr<<"Error "<< errorCode << ": " <<Message<<endl;
}
DataSizeFullException(){
errorCode=1000;
Message = "You've reached the maximum capacity.";
}
//virtual ~DataSizeFullException(){
//}
private:
int errorCode;
string Message;
};
#endif // DATASIZEFULLEXCEPTION_H_INCLUDED
This is the function where DataSizeFullException gets thrown into.
1 2 3 4 5 6 7 8
void Statistics::add (double value) throw (DataSizeFullException){
if (size<capacity){ //conditions for the exception
pData[size]=value;
size++;
}
else {throw DataSizeFullException();}
}
And this is my static void test function where I implement try and catch. The issue I'm having is that between the brackets of try and catch. My DataSizeFullException seems to ignore the rest of the functions with in the block and continues to print the exception, no matter the way i change the conditions. Statistics is another class where i'm implementing the DataSizeFullException.
Well in my add function, size is supposed to increment within the add function. I did nonetheless attempt your recommendation and the issue still remains.