473,395 Members | 1,574 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,395 software developers and data experts.

error in c++ code

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. class fraction
  4. {
  5.       int num;
  6.       int den;
  7.       public:
  8.              fraction(int n,int d=1)
  9.              {
  10.                           num=n;
  11.                           den=d;
  12.              }
  13.  
  14.              fraction operator +(fraction temp);
  15.              fraction operator -(fraction temp);
  16.              fraction operator *(fracion temp);
  17.              fraction operator /(fraction temp);
  18.              fraction min(fraction temp);
  19.              void display(fraction temp);
  20.  
  21. }
  22.  
  23. fraction fraction::operator +(fraction temp)
  24. {
  25.          fraction hold;
  26.  
  27.          if(den==temp.den)
  28.          {
  29.                           hold.num=num+temp.num;
  30.                           hold.den=den;
  31.                           return hold;
  32.          }
  33.          else
  34.          {
  35.              hold.num=num*temp.den+temp.num*den;
  36.              hold.den=den*temp.den;
  37.              hold=min(hold);
  38.              return hold;
  39.          }
  40. }
  41.  
  42. fraction fraction::operator -(fraction  temp)
  43. {
  44.  
  45.          fraction hold(10);
  46.  
  47.          if(den==temp.den)
  48.          {
  49.                           hold.num=num-temp.num;
  50.                           hold.den=den;
  51.                           return hold;
  52.          }
  53.          else
  54.          {
  55.              hold.num=num*temp.den-temp.num*den;
  56.              hold.den=den*temp.den;
  57.              hold=min(hold);
  58.              return hold;
  59.          }    
  60.  
  61. }
  62.  
  63. fraction fraction::operator *(fraction  temp)   
  64. {
  65.          fraction hold(10);
  66.          hold.num=num*temp.num;
  67.          hold.den=den*temp.den;
  68.          hold=min(hold);
  69.          return hold;
  70. }
  71.  
  72. fraction fraction::operator /(fraction  temp)
  73. {
  74.          fraction hold;
  75.          hold.num=num/temp.num;
  76.          hold.den=den/temp.den;
  77.          hold=min(hold);
  78.          return hold;
  79. }
  80.  
  81. void fraction::display(fraction temp)
  82. {
  83.      cout<<"\n "<<temp.num<<"/"<<temp.den<<"\n";
  84. }
  85.  
  86. void fraction::min(fraction temp)
  87. {
  88.      int i;
  89.      for(i=temp.den;i>=2;i--)
  90.      {
  91.                         if((yemp.num%i==0)&&(temp.den%i==0))
  92.                         {
  93.                                                   temp.num=temp.num/i;
  94.                                                   temp.den=temp.den/i;
  95.                         } 
  96.      }
  97. }                      
  98.  
  99. int main()
  100. {
  101.     fraction use;
  102.     cout<<"enter num of fraction 1\n";
  103.     cin>>num1;
  104.     cout<<"enter den of fracion 1\n";
  105.     cin>>den1;
  106.     cin>>num2;
  107.     cin>>den2;
  108.     fraction f1(num1,den1);
  109.     fraction f2(num2,den2);
  110.     fraction temp;
  111.     temp=f1+f2;
  112.     use.display(temp);
  113.     temp=f1-f2;
  114.     use.display(temp);
  115.     temp=f1*f2;
  116.     use.display(temp);
  117.     temp=f1/f2;
  118.     use.display(temp);
  119.     system("pause");
  120. }


I AM GETTING AN ERROR AS "DECLARATION OF 'OPERATOR*' NON FUNCTION" WHILE THE OTHER OVERLOADED OPERATORS COMPILE SUCCESSFULLY.
Oct 17 '11 #1
1 1544
weaknessforcats
9,208 Expert Mod 8TB
You are missing a semi-colon at the end of your class declaration.
Oct 17 '11 #2

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

Similar topics

2
by: Mike Fisher | last post by:
I'm seeing an error when I try to run/debug a web service. Although it doesn't happen every time, it does occur more than half of the times I hit F5. It appears to be returned by the the JIT...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
3
by: Antoine | last post by:
Hello, I'm writing a program to send requests to my wlan pocket pc device (UIO1: driver) in C#. Here how I import CreateFile functions from coredll.dll with DllImport: public static extern...
5
by: frazer | last post by:
hi i want to get the error code when an error occurs. is catch(Exception ex) { ex.GetHashCode() //will this return a unique number for every error? }
3
by: Hamilton | last post by:
Hi there, I've seen this error appear a few times in newsgroups but unfortunately I haven't found one that actually provides a solution. I'm basically deploying a new website into an area at a...
1
by: Razzie | last post by:
Hi all, I was working on a little project, worked fine, but now all of a sudden I get: The compiler failed with error code -1073741502 as an error message (when running the site, not...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
1
by: delusion7 | last post by:
Trying to create a table and insert records from a webform and I keep getting this message: "Successfully created the registration table. Unable to execute the query. Error code...
4
by: Pool | last post by:
I tried to connect DB2 (Sitting in Unix server at my client location) using Db2 connect V8. I am getting the following error message. I tried all the possible options BUt the error is same.. See each...
2
by: sareena | last post by:
There is a problem with accessing an ASP appln hosted on a dedicated Win '03 load balanced server running IIS 6.0 in worker process isolation mode. When the user types in the URl of the appln and...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.