0

Howdy guys. I have a program that encompasses creating a Fraction class. In the Fraction class should encompass addition, subtraction, multiplication, and division, and printing out the fraction. For some reason, UNIX hates my cout that I am using in my print. Here are the header and implication files for the class.

Header File

```
#include<iostream>
class Fraction
{
public:
Fraction();
void setNum(int);
void setDen(int);
int getNum();
int getDen();
Fraction Add(Fraction);
Fraction Sub(Fraction);
Fraction Multiply(Fraction);
Fraction Divide(Fraction);
bool IdenticalCompare(Fraction);
bool ReduceCompare(Fraction);
void Print();
private:
int num;
int den;
void Simplify();
};
```

Implementation

```
#include <iostream>
#include "fraction.h"
void Fraction:: Simplify()
{
for(int x = num*den;x>=num;--x)
{
if(den%x==0&&num%x==0)
{
num /= x;
den /= x;
}
}
}
Fraction:: Fraction()
{
num = 1;
den = 1;
}
//assigning num with the parameter
void Fraction::setNum(int n)
{
num=n;
}
//assigning den with the parameter
void Fraction::setDen(int d)
{
den=d;
}
int Fraction::getNum()
{
return num;
}
int Fraction::getDen()
{
return den;
}
void Fraction:: Print()
{
cout<<num<<"/"<<den;
}
Fraction Fraction:: Add(Fraction f2)
{
Fraction f3;
f3.num = num*f2.den+f2.num*den;
f3.den = den*f2.den;
f3.Simplify();
return f3;
}
Fraction Fraction:: Sub(Fraction f2)
{
Fraction f3;
f3.num = num*f2.den - f2.num*den;
f3.den = den*f2.den;
f3.Simplify();
return f3;
}
Fraction Fraction:: Multiply(Fraction f2)
{
Fraction f3;
f3.num = num*f2.num;
f3.den = den*f2.den;
f3.Simplify();
return f3;
}
Fraction Fraction:: Divide(Fraction f2)
{
Fraction f3;
f3.num = num*f2.den;
f3.den = f2.num*den;
f3.Simplify();
return f3;
}
bool Fraction:: IdenticalCompare(Fraction f2)
{
if(num==f2.num&&den==f2.den)
return true;
else
return false;
}
bool Fraction:: ReduceCompare(Fraction f2)
{
Simplify();
f2.Simplify();
if(num==f2.num&&den==f2.den)
return true;
else
return false;
}
```

The error I am getting is:

```
error: 'cout' undeclared (first use this function)
```

I am also using UNIX if this is any useful information. If there is any other information needed, please let me know.

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting