Fraction Library
A C++ Fraction library.
|
This file defines error conditions that can result when using Fraction and MFraction classes. More...
Go to the source code of this file.
Defines | |
#define | FR_DENOM_ZERO ((FR_ERROR)1) |
A value FR_ERROR takes when a fraction's denominator is equal to 0. | |
#define | FR_STR_INVALID ((FR_ERROR)2) |
A value FR_ERROR takes when a string value can't be converted into a fraction. | |
#define | FR_INDEX_OUT_BOUNDS ((FR_ERROR)3) |
A value FR_ERROR takes when index is out of bounds when using the [] operator to access the private member variables. | |
#define | FR_NEG_PARAM ((FR_ERROR)4) |
A value FR_ERROR takes when a positive integer is expected but a negative value is passed in. | |
Typedefs | |
typedef unsigned short | FR_ERROR |
Fraction error code variable: stores the type of error incurred. |
This file defines error conditions that can result when using Fraction and MFraction classes.
For instance, when the user tries to initilize a fraction object with a denominator of 0, this is not valid and an exception will be thrown of type FR_ERROR with value of FR_DENOM_ZERO. See details below.
#include "Fraction.h" int main() { short x; cin >> x; //try a very very large number, the program will not exit with an error code cout << x; //instead, you will get an incorrect result std::cin.get(); return (0); }
Definition in file FracError.h.
#define FR_DENOM_ZERO ((FR_ERROR)1) |
A value FR_ERROR takes when a fraction's denominator is equal to 0.
Definition at line 34 of file FracError.h.
#define FR_INDEX_OUT_BOUNDS ((FR_ERROR)3) |
A value FR_ERROR takes when index is out of bounds when using the [] operator to access the private member variables.
Definition at line 42 of file FracError.h.
#define FR_NEG_PARAM ((FR_ERROR)4) |
A value FR_ERROR takes when a positive integer is expected but a negative value is passed in.
Definition at line 45 of file FracError.h.
#define FR_STR_INVALID ((FR_ERROR)2) |
A value FR_ERROR takes when a string value can't be converted into a fraction.
Definition at line 37 of file FracError.h.
typedef unsigned short FR_ERROR |
Fraction error code variable: stores the type of error incurred.
Definition at line 31 of file FracError.h.