i've tried to multiply 2 large numbers represented as linked lilsts(overload the operator*) but there seems to be an error. could any of you help me, please ? i think that the multiply function is correct since i've tested it. but i can't seem to put the finger on what's wrong when i try to overload the operator*..... i've tried looping through one list and mutiply with each node from the other one.. extra a tip for dividing 2 large numbers ? thank you! here is my code:
Numar *Numar :: operator* (Numar *nr2) //overloading operator*
{
Lista *L = new Lista;
Numar *rezultat = new Numar(L);//links the list to the number
Lista *aux = new Lista;
Numar *rez2 = new Numar(aux); //an auxiliary
int t = 1;
Nod *p2 = this->L->prim; //1st node of this
while (p2) //loop the 2nd number
{
rez2 = nr2->multiply(p2->info * t); //multiply the 1st list with an int
cout<<"rez2 "<<rez2;
rezultat = *rezultat + rez2;
cout<<"rezultat "<<rezultat;
t *= 10; //that carry
p2 = p2->next;
}
return rezultat;
}
for full code https://pastebin.com/PcXuM9EL