Files to submit
Authorized
Definition of done
Add the following public constructors and public member functions to the class
Testing
Running this code:
#include <iostream>
int main( void ) {
Fixed a;
Fixed const b( 10 );
Fixed const c( 42.42f );
Fixed const d( b );
a = Fixed( 1234.4321f );
std::cout << "a is " << a << std::endl;
std::cout << "b is " << b << std::endl;
std::cout << "c is " << c << std::endl;
std::cout << "d is " << d << std::endl;
std::cout << "a is " << a.toInt() << " as integer" << std::endl;
std::cout << "b is " << b.toInt() << " as integer" << std::endl;
std::cout << "c is " << c.toInt() << " as integer" << std::endl;
std::cout << "d is " << d.toInt() << " as integer" << std::endl;
}
Should output something similar to:
$> ./a.out
Default constructor called
Int constructor called
Float constructor called
Copy constructor called
Copy assignment operator called
Float constructor called
Copy assignment operator called
Destructor called
a is 1234.43
b is 10
c is 42.4219
d is 10
a is 1234 as integer
b is 10 as integer
c is 42 as integer
d is 10 as integer
Destructor called
Destructor called
Destructor called
Destructor called
$>
Files to submit
ex01/dirAuthorized
Definition of done
Add the following public constructors and public member functions to the class
float toFloat( void ) const;that converts the fixed-point value to a floating-point valueint toInt( void ) const;that converts the fixed-point value to an integer value<<operator that inserts a floating-point representation of the fixed-point number into the output stream object passed as a parameterTesting
Running this code:
Should output something similar to: