Hello ...
Now , When I write this massege I feel with a huge disappointment becouse I waste 6 houers to konow what is the Problem with this code .
The I didn't write the hole code , becouse every thing was Ok Until I want to OverLoad the + operation using friend function , the compiler give me this massege :
INTERNAL COMPILER ERROR
The binfit of the programe is to add Fraction using class and the overload all the artheamtic operations
I need help please , becouse I have to complete it befoe Saturday and I have also MATH MAJOR
---------------------------------------------
This is .h file :
#include <iostream>
using namespace std ;
class Fraction
{
private :
double numerator ;
double denominator ;
public :
friend Fraction operator +(Fraction &a , Fraction &b ) ;
Fraction () ;
Fraction ( double x , double y ) ;
bool zero () ;
bool infinite () ;
void print () ;
void print_decimal () ;
friend istream &operator>> ( istream &ins , Fraction &f )
{
cout << "Enter the Fraction " << endl;
ins >> f.numerator ;
ins >> f.denominator ;
return ins ;
}
};
-------------------------------------
This is .cpp file :
///////// Fraction.cpp ///////
///////////////////////////////
#include <iostream>
#include <iomanip>
#include "Fraction.h "
using namespace std ;
Fraction::Fract ion()
{
numerator = 1 ;
denominator = 1 ;
}
Fraction::Fract ion ( double x , double y )
{
numerator = x ;
denominator = y ;
}
bool Fraction::zero( )
{
if ( numerator == 0 )
return 0 ;
else
return ( false ) ;
}
bool Fraction::infin ite ()
{
if ( denominator == 0 )
return ( true ) ;
else
return ( false ) ;
}
void Fraction:rint ()
{
if ( infinite () == true )
cout << " oo " << endl;
else
cout << "Fraction as fraction " << setw(5) << "==" << setw(5) << numerator << "/" << denominator << endl;
}
void Fraction:rint_d ecimal ()
{
cout << "Fraction as dicimal " << setw(5) << "==" << setw(5) << numerator / denominator << endl;
}
Fraction operator+(const Fraction &a , const Fraction &b)
{
Fraction tempC;
tempC.numerator =a.numerator +b.numerator;
tempC.denomerat or=a.denomerato r+b.denomerator ;
return tempC;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//I tryed to Overload >> by this way , But it was filled !!!!!
///////////////////////////////////////////////////////////////
//Fraction Fraction:perato r >>(istream &ins )
///{
// Fraction f ;
///
// cout << "Enter Fraction " << endl;
// ins >> f.numerator ;
// ins >> f.denominator ;
//
// return f ;
//}
Now , When I write this massege I feel with a huge disappointment becouse I waste 6 houers to konow what is the Problem with this code .
The I didn't write the hole code , becouse every thing was Ok Until I want to OverLoad the + operation using friend function , the compiler give me this massege :
INTERNAL COMPILER ERROR
The binfit of the programe is to add Fraction using class and the overload all the artheamtic operations
I need help please , becouse I have to complete it befoe Saturday and I have also MATH MAJOR
---------------------------------------------
This is .h file :
#include <iostream>
using namespace std ;
class Fraction
{
private :
double numerator ;
double denominator ;
public :
friend Fraction operator +(Fraction &a , Fraction &b ) ;
Fraction () ;
Fraction ( double x , double y ) ;
bool zero () ;
bool infinite () ;
void print () ;
void print_decimal () ;
friend istream &operator>> ( istream &ins , Fraction &f )
{
cout << "Enter the Fraction " << endl;
ins >> f.numerator ;
ins >> f.denominator ;
return ins ;
}
};
-------------------------------------
This is .cpp file :
///////// Fraction.cpp ///////
///////////////////////////////
#include <iostream>
#include <iomanip>
#include "Fraction.h "
using namespace std ;
Fraction::Fract ion()
{
numerator = 1 ;
denominator = 1 ;
}
Fraction::Fract ion ( double x , double y )
{
numerator = x ;
denominator = y ;
}
bool Fraction::zero( )
{
if ( numerator == 0 )
return 0 ;
else
return ( false ) ;
}
bool Fraction::infin ite ()
{
if ( denominator == 0 )
return ( true ) ;
else
return ( false ) ;
}
void Fraction:rint ()
{
if ( infinite () == true )
cout << " oo " << endl;
else
cout << "Fraction as fraction " << setw(5) << "==" << setw(5) << numerator << "/" << denominator << endl;
}
void Fraction:rint_d ecimal ()
{
cout << "Fraction as dicimal " << setw(5) << "==" << setw(5) << numerator / denominator << endl;
}
Fraction operator+(const Fraction &a , const Fraction &b)
{
Fraction tempC;
tempC.numerator =a.numerator +b.numerator;
tempC.denomerat or=a.denomerato r+b.denomerator ;
return tempC;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//I tryed to Overload >> by this way , But it was filled !!!!!
///////////////////////////////////////////////////////////////
//Fraction Fraction:perato r >>(istream &ins )
///{
// Fraction f ;
///
// cout << "Enter Fraction " << endl;
// ins >> f.numerator ;
// ins >> f.denominator ;
//
// return f ;
//}
Comment