سلام دوستان
من می خوام یه کلاس برای ضرب و جمع اعداد بزرگ مثلا اعداد 20 رقمی بنویسم
من یه اشاره گر به اسم arr و یه متغییر به اسم Len دارم که طول شی یعنی همون آرایه رو در خودش نگه میداره
به علاوه یه تابع fix دارم که که مثلا اگر شی اول یه عدد دورقمی مثل 25 و دومی سه رقمی مثل 152 باشه شی اول رو به صورت 025 باز سازی میکنه

توی نت سرچ کردم نوشته بود باید سه جز یعنی سازنده کپی ، مخرب و عملگر تساوی رو با هم بنویسی تا درست کار کنن اما وقتی تابع سازنده کپی و مخرب رو نوشتم برنامه خطا ی trigeged breakpointer می داد که فک کنم یعنی به بخشی از حافظه دسترسی پیدا می کنیم که مجاز نیستیم

من تابع سازنده و مخرب رو این طوری تعریف کردم :

l_int(const l_int &source)
{
Len=source.Len;
arr=new int[Len+1];
for(int i=0;i<Len;i++)
arr[i]=source.arr[i];
}

~l_int()
{
delete [] arr;
}

کسی ایده ای به ذهن ش می رسه که چه طور باید این موضوع رو حل کنم
بی نهایت ممنون

این م کل کد:

// BigNumber.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include <iostream>




using namespace std;


class l_int
{
private:
int *arr;
int Len;
protected:
void fix(l_int temp)//Fix Lenght of any Array
{


if(Len<temp.Len)
{
int *backup=new int[Len];
for(int i=0;i<Len;i++)
backup[i]=arr[i];


delete []arr;


arr=new int[temp.Len+1];
for(int i=0;i<Len;i++)
arr[i]=backup[i];


delete []backup;


for(int i=Len;i<temp.Len;i++)
arr[i]=0;


Len=temp.Len;
}
else
{
int *backup=new int[temp.Len];
for(int i=0;i<temp.Len;i++)
backup[i]=temp.arr[i];


delete []temp.arr;


temp.arr=new int[Len];
for(int i=0;i<temp.Len;i++)
temp.arr[i]=backup[i];


delete []backup;


for(int i=temp.Len;i<Len;i++)
temp.arr[i]=0;


temp.Len=Len;
}
}


public:
void set()
{
char txt[20];
gets_s (txt);
Len=strlen(txt);
arr= new int[Len+1];
for(int i = 0 ; i<Len ;i++)
arr[i]=txt[strlen(txt)-1-i]-48;
}
void show()
{
bool Check=false;
for(int i=Len-1;i>=0;i--)
if(arr[i]>0 || Check==true)
{
cout<<arr[i];
Check=true;
}
if(Check==false)
cout<<"0";
}


friend ostream& operator <<(ostream &out,l_int temp);
friend istream& operator >>(istream &in,l_int &temp);

l_int(const char txt[]="")
{
Len=strlen(txt);
arr= new int[Len+1];
for(int i = 0 ; i<Len ;i++)
arr[i]=txt[strlen(txt)-1-i]-48;
}

l_int(const l_int &source)
{
Len=source.Len;
arr=new int[Len+1];
for(int i=0;i<Len;i++)
arr[i]=source.arr[i];
}

~l_int()
{
delete [] arr;
}



l_int& operator + (l_int &temp)
{
fix(temp);
l_int Sum;


Sum.arr= new int[Len+1];
Sum.Len=Len+1;


int sum=0;
for(int i=0;i<Len;i++)
{
Sum.arr[i]= ( arr[i] + temp.arr[i] +sum) %10;
sum=( arr[i] + temp.arr[i] +sum ) /10;
if(i==Len-1 && sum>0)
Sum.arr[Len]=sum;
}


return Sum;
}


l_int& operator *(l_int &temp)
{
fix(temp);


arr[Len]=0;
temp.arr[temp.Len]=0;
int sum;


l_int Mult;
Mult.arr= new int[Len+temp.Len];
Mult.Len=Len+temp.Len;


for(int i=0;i<Len+temp.Len;i++)
Mult.arr[i]=0;


for(int i=0;i<=temp.Len;i++)
{
sum=0;
for(int j=0;j<=Len;j++)
{


Mult.arr[i+j]+=(arr[j]*temp.arr[i]+sum)%10;
if(Mult.arr[i+j]>9)
{
Mult.arr[i+j]=Mult.arr[i+j]%10;
Mult.arr[i+j+1]++;
}
sum=(arr[j]*temp.arr[i]+sum)/10;
}
}
return Mult;
}


l_int& operator =(l_int &temp)
{
Len=temp.Len;
arr=new int[Len];
for(int i=0;i<Len;i++)
arr[i]=temp.arr[i];
return *this;
}






};


ostream& operator <<(ostream &out,l_int temp)
{
bool Check=false;
for(int i=temp.Len-1;i>=0;i--)
if(temp.arr[i]>0 || Check==true)
{
cout<<temp.arr[i];
Check=true;
}
if(Check==false)
cout<<"0";
return out;
}


istream& operator >>(istream &in,l_int &temp)
{
char txt[20];
gets_s (txt);
temp.Len=strlen(txt);
temp.arr= new int[temp.Len+1];
for(int i = 0 ; i<temp.Len ;i++)
temp.arr[i]=txt[strlen(txt)-1-i]-48;
return in;
}




int _tmain(int argc, _TCHAR* argv[])
{


l_int A,B;
// cin>>A>>B;
A.set();
B.set();


cout<<A+B<<endl;
cout<<A*B<<endl;


l_int C="110";
l_int D,E;
D=E=C;
cout<<endl<<D<<','<<E<<endl;


system("pause");
return 0;
}