473,486 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to solve iiegeal structure opearion error in binary opeartor overloading?

1 New Member
Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3. class sum
  4. {
  5.     int a,b,ans;
  6. public:
  7. void  geta()
  8. {
  9.   cin>>a;
  10.   return a;
  11. }
  12. void getb()
  13. {
  14.     cin>>b;
  15.  
  16.  
  17. }
  18. void operator+()
  19.  
  20. {
  21.     ans=a+b;
  22. }
  23. void disp()
  24. {
  25.     cout<<ans;
  26. }
  27. };
  28. void main()
  29. {
  30.   sum s,s1,s2;
  31.   int a,b;
  32.   s1.geta();
  33.   s2.getb();
  34.   s=b+a;
  35.   s.disp();
  36. }
Aug 1 '13 #1
1 1442
weaknessforcats
9,208 Recognized Expert Moderator Expert
The variable s is an object of the class sum:

Expand|Select|Wrap|Line Numbers
  1. s=b+a;
  2.  
There is no method in class sum on how to assign an int (a+b) to a sum object. That is, you need a sum::operator(int) method.

That said, what are you trying to do? I am having trouble following your logic in main().
Aug 1 '13 #2

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

Similar topics

3
2805
by: Kashyap | last post by:
i have a project in which i have used crystal report. when i run this application on other computer which has a microsoft framework install give me error when open the form containing the crystal...
5
4315
by: Phil Kelly | last post by:
Hi I need to write the contents of a structure to a binary file - there is one string and 2 integers, but I can't seem to figure out how to write the data correctly. If I am simply writing...
9
2478
by: gamehack | last post by:
Hi all, I've been wondering when I write a structure like: struct { int a; unsigned int b; float c; } mystruct;
2
8209
by: Eric Renken | last post by:
I have a Windows .NET 2.0 application that has been working fine for last year, and now all of a sudden on one customers computer I am getting this error, "Binary format of the specified custom...
10
7463
by: =?Utf-8?B?TmFuZCBLaXNob3JlIEd1cHRh?= | last post by:
I have a binary file created using C++ that contains an object of the structure: struct student { int roll_no; char name; char qualification; };
2
4844
by: ZeroBlack | last post by:
Hi, I would like to know if there's a function to delete a structure from a binary file and replace in the same place with the same structure but with other values. this is the structure i'm...
0
1072
by: vincent90152900 | last post by:
I'm trying to get PowerShell script to run a program. Here is the command line I need to run: "\"C:\\Program Files\\PDF2allTest\\pdf2all\" -c pdf2jpg -s \"c:\\test\\test\\01.pdf\" -or 600" I...
4
27178
by: hatem0 | last post by:
Hi all I don't know if I am in the right forum, I hope that someone can help me. I am not a programer, my problem is when I open a website like facebook or howstuffworks the page don't open...
3
1802
chandru8
by: chandru8 | last post by:
when iam trying to execute this statement Set OutlookApp = CreateObject("Outlook.Application") iam getting a runtime error 429 what are the things to be added to solve this issue
0
917
by: manish m pawade | last post by:
Sir, i am a mechanical Ph.D student and i am attempting to develop a programme for my Ph.D.where in that progarmme their is no error but when i run that programme one error comes that is "Retrieving...
0
7094
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
7123
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
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6839
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
7305
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...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.