How to add two binary number using + operator overloading in C++?
-
How to add two binary number using + operator overloading in C++. Suppose my program is as follow: Order should be from least significant bit to most significant bit. string that store array should be pointer like (*s) because of unlimited size. Addition should be done from left to right (not right to left) class LBI { char *str; public: int len; LBI(char*); LBI operator+(LBI); }; void main() { clrscr(); LBI obj("101010"); LBI obj2("1111"); LBI o = obj+obj2; getch(); } LBI :: LBI(char* s) { len = strlen(s); for(int i=0; i<len; i++) { if(s[i] != '0' && s[i] != '1') { cout<<"Your string contains some Invalid chars\n"; cout<<"Can't initialize Object"; getch(); exit(0); } } str = s; } LBI LBI :: operator+(LBI c) { //place your code here }
-
Answer:
01,01
Harsh at Yahoo! Answers Visit the source
Other answers
01,01
Scooterpoop, the other white mea...
Related Q & A:
- How To Connect Two Different Network Segments Using A Switch And A Router?Best solution by Super User
- How to add inline xml schema using jaxb?Best solution by bighow.org
- how to dial phone number using .NET?Best solution by Stack Overflow
- How to add image to QTextBrowser using Python?Best solution by Stack Overflow
- How to add two variable in bash?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.