Hi, I am having trouble understanding what a set of instructions on my homework means. The part is Casting: Rational numbers should be able to be implicitly cast to floats and double, and implicitly cast from integers. Would anyone be able to explain a little what this could mean? Is it simply casting ints to floats or doubles to make comparison easier?
the full instructions are below if that will help.
Write a class to represent rational numbers. Unlike floating point numbers, rational numbers do not suffer from finite precision. The numbers should be stored in their simplest form. The following operations are required:
Casting: Rational numbers should be able to be implicitly cast to floats and double, and implicitly cast from integers.
Comparison: All of the comparison operators <, > , == , <= , >= . != should be implemented
Arithmetic: All of the arithmetic operators, +, +=, *, *=, /, /= -, -= should be implemented
I/O: Stream insertion and extraction << and >> should be implemented
You must also provide a main program that demonstrates the full capability of your rational number class.