How can we add two array?

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

Was this solution helpful to you?

Other answers

01,01

Scooterpoop, the other white mea...

Related Q & A:

Just Added Q & A:

Find solution

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.