473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PLEASE I need a Quick HELP

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::Fraction()
{
numerator = 1 ;
denominator = 1 ;
}

Fraction::Fraction ( double x , double y )
{
numerator = x ;
denominator = y ;
}

bool Fraction::zero()
{
if ( numerator == 0 )
return 0 ;
else
return ( false ) ;
}

bool Fraction::infinite ()
{
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_decimal ()
{
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.denomerator=a.denomerator+b.denomerator;
return tempC;
}

/////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////
//I tryed to Overload >> by this way , But it was filled !!!!!
///////////////////////////////////////////////////////////////
//Fraction Fraction:perator >>(istream &ins )
///{
// Fraction f ;
///
// cout << "Enter Fraction " << endl;
// ins >> f.numerator ;
// ins >> f.denominator ;
//
// return f ;
//}
Mar 22 '07 #1
6 1607
Roonie
99
ok, first, if youre going to ask us for help, do NOT start by saying what a disappointment it is that it will take so long.

(i dont know about others, but i personally will require an apology before helping you.)
Mar 22 '07 #2
ok, first, if youre going to ask us for help, do NOT start by saying what a disappointment it is that it will take so long.

(i dont know about others, but i personally will require an apology before helping you.)
Ok ... I'm sorry ...

now please give me what you have ..

Thanks
Mar 23 '07 #3
Roonie
99
i am trying very hard to understand
now please give me what you have ..
as a very PATIENT now-please-give-me-what-you-have . . .

. . .

anyways, you have this:
Expand|Select|Wrap|Line Numbers
  1. tempC.denomerator=a.denomerator+b.denomerator;
when you declare both numerator and denomiator as private members . . . meaning that you need to use a function to access them instead of the dot operator. (and check your typos.)

also, if you are overloading the + operator, you should only give one parameter to the overload function. when you use the overloaded function, you are using the + of one fraction, so you have one fraction already and thus you only need to (can) specify one other fraction to add with.

you also need to check your algebra:
(a/b)+(c/d) does not equal ((a+c)/(b+d)).

check:
http://www.devarticles.com/c/a/Cplus...ing-in-C-plus/
Mar 23 '07 #4
Roonie
99
you declare both numerator and denomiator as private members . . . meaning that you need to use a function to access them instead of the dot operator.
(maybe the friend operator changes this, im not sure, ive not used it much personally. but i would fix up your overload + function before trying to determine the exact effects of this keyword on that function.)
Mar 23 '07 #5
Roonie
99
well, it looks like its my turn to apologize . . .

i guess that using friend with an operator over load allows both operands to be passed as parameters . . .
http://www.see.ed.ac.uk/~sasg/Comput.../Cpp/cpp6.html
. . . i think im slightly outdated.:(

but you still do have typos in your code. (denomerator != denominator)
Mar 23 '07 #6
i am trying very hard to understand

as a very PATIENT now-please-give-me-what-you-have . . .

. . .

anyways, you have this:
Expand|Select|Wrap|Line Numbers
  1. tempC.denomerator=a.denomerator+b.denomerator;
when you declare both numerator and denomiator as private members . . . meaning that you need to use a function to access them instead of the dot operator. (and check your typos.)

also, if you are overloading the + operator, you should only give one parameter to the overload function. when you use the overloaded function, you are using the + of one fraction, so you have one fraction already and thus you only need to (can) specify one other fraction to add with.

you also need to check your algebra:
(a/b)+(c/d) does not equal ((a+c)/(b+d)).

check:
http://www.devarticles.com/c/a/Cplus...ing-in-C-plus/
First of all , thanks my new friend Roonie for your replying

But the methode that you mentioned aboev is anothoer way to overload operations ..

Yestaday after I post my problem here, I go througth internet and I looked for ( Internal Compiler Error ) .

The resuld shoced me ... The error was from Microsoft co. and they have an update for such errors .,

Becouse the file was little bit big , I asked samoebody to download it
and I will try again ...

Thanks again ....

....................................GoodBye....... ........
Mar 23 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: anthonyberet | last post by:
I work for an organisation that uses a bespoke document imaging system, the database of which is an MS sql server. We have MS Access and already use it for some querying of the database. The...
5
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide,...
14
by: TrvlOrm | last post by:
OK. After much playing around, I managed to get my frame page this far.. see code below. BUT...there are still errors with it, and what I would like to have happened is this: 1) On the Left...
4
by: Madhu Gopinathan | last post by:
Hi All, I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor....
60
by: sasan3 | last post by:
I hate people who post messages to complain about others posting to multiple newsgroups, or condescendingly point to the documents in answer to a question, or sarcastically hint at the triviality...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
13
by: sd00 | last post by:
Hi all, can someone give me some coding help with a problem that *should* be really simple, yet I'm struggling with. I need the difference between 2 times (Target / Actual) However, these times...
10
by: Miro | last post by:
I wanted certain text boxes ( only certain ones ) to always be Trim'd so that spaces are not in the begining, nor the end of the text entered. I created my own "Handle ?" - i hope thats the...
1
by: bartman1973 | last post by:
Hi guys and gals, i am new in C++ and would like to seek some help. I just transfered to this new department and now they are asking me to do some programming. I am just in the process of...
7
by: pooh1119 | last post by:
hi. my code below makes use of NTL(a library for doin number theory available at www.shoup.net); im trying to print the double base number representation of any large number(32 bits and/or more) but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.