vendredi 23 octobre 2020

two big string number for using addition overloading operator

using namespace std; class bigNum {

char *digits;
int length;
string disp_mode;
bool invalidNumber;

public:
bigNum(string number);

}

bigNum::bigNum(string number) {

 this-> disp_mode = number;

 int numlength = disp_mode.length();
 
 digits = new char[disp_mode.length()+1];
 
 int val_1 = atoi(digits);   //need to convert from char array to int 
 
for(int i=0; i<numlength; i++)
{
    digits[i] = disp_mode[i];
}

}

int main() {

cout << "Creating numbers..." << endl;

bigNum num1("838473881983479981738");
bigNum num2("109394883190395484839");

cout << "add: num3=num1+num2" << endl;
num3 = num1+num2;
cout << "number num3=" << num3 << endl;

}

Aucun commentaire:

Enregistrer un commentaire