With this exercise we are continuing our exploration of clas

With this exercise, we are continuing our exploration of classes and objects. The purpose of this assignment is to get you familiar with overloading functions (methods) in object. Using the Header File / Source Code File format modify the PSA 10 class.

You will need to create three overloaded functions, all with the name compare, in the object source file. The header has already been built for you; it should need no modification. Your object should be able to compare the length of two strings, the values of two doubles, or the value of a double and an int32_t. If the first argument is larger than the second argument the method should return true. Otherwise, it should return false.

The introductory comments should also contain the purpose of the program. Clear, concise, commenting is an important skill to develop and will be part of the grade for each program.

Program it on CODE::BLOCK.

The below is PSA 10 class:

#include \"example.h\"

#include <string>

using namespace std;

example::example()

{

    //ctor

}

example::~example()

{

    //dtor

}

// Your three overloaded methods go here.

Thank you.

Solution

1) comparing length of two string:

bool example(string str1,string str2)

{

if(str1.size() >str2.size())

return true;

else

return false;

}

2) comparing the value of two doubles

bool example(double no1,double no2)

{

if(no1> no2)

return true;

else

return false;

}

3) comparing value of double and integer

bool example(double no1,int no2)

{

if(no1 > (double) no2)

return true;

else

return false;

}

With this exercise, we are continuing our exploration of classes and objects. The purpose of this assignment is to get you familiar with overloading functions (
With this exercise, we are continuing our exploration of classes and objects. The purpose of this assignment is to get you familiar with overloading functions (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site