I have had a lot of problems with C++ and I am quite confused. Here is the code so far;
#include <iostream.h>
#include <stdlib.h>
#include <cstring>
#include <cctype>
class Fraction
{
private:
Fraction ();
Fraction (double);
Fraction (Fraction &);
public:
double operMultiplication ();
double operSum ();
double operDouble ();
double operEqual ();
double operSet ();
double getNumerator ();
void setNumerator (double numerator);
double getDenominator ();
void setDenominator (double denominator);
};
using namespace std;
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}
Here is what I need to do, from what code I have done does it look like im on the right track and if not what should I change?;
Name the class "Fraction". Create three constructors for the class. The first constructor (the default constructor) will assign 1 for the numerator and 1 for the denominator. Create an overloaded constructor that takes two integer arguments. This argument will allow the class user to specify the numerator and the denominator. Finally, you must create a copy constructor.
The class must have a private data members for the numerator and the denominator. You may add as many other private variables as necessary to implement the remainder of the assignment. You should not have any public variables unless they are constants. Do not allow the numerator to be less than one. Do not allow the denominator to be less than one.
The class must also have the following functions. These functions should all be public.
operator* - Return a new Fraction object that is the product of two existing Fraction objects.
operator+ - Return a new Fraction object that is the sum of two existing Fraction objects.
operator double - Return the value of the Fraction object as a double. Divide the numerator by the denominator to get this result.
operator= - Assign the value of one Fraction object to another Fraction object.
operator== - Compare the values of each data member in one object to the respective value of the data members in a second object. The objects are equal if the respective data elements are equal. Return true if the objects are equal. Return false if they are not equal.
getNumerator - Return the class numerator.
getDenominator - Return the class denominator.
setNumerator - Receive one integer argument and update the class numerator.
setDenominator - Receive one integer argument and update the class denominator if the argument isn't zero. Default to one if the argument is zero.
You do not need a destructor for this class.
Do not use any inline functions.