I need to create an array of classes; something like; I have a class named calculate, and I need to create an array of the class like:
claculate array[1000];
is that possible? I tried this...and it compiles alright....but when I run the program...it gives a segmentation fault. Please suggest how I can do this!!
Thanks
Shrestha
Here is a snippet of what I need to do:
Code tags added by Kermi3Code:calculate operator *(calculate big1, calculate big2)
{
calculate ans[1000];
int temp=0;
int temp1=0;
int temp2=0;
for (int i=1; i<big2.count+1;i++)
{
for(int y=big1.count; y>0; y--)
{
temp1=big1.array1[y]*big2.array1[i]+temp;
temp=0;
if (temp1>9)
{
temp=temp1/10;
temp1=temp1-temp*10;
}
ans[i].array1[y]=temp1;
}
ans[i].count=big1.count;
if (temp != 0)
{
for (int j=ans[i].count+1; j>0; j--)
{
ans[i].array1[j]=ans[i].array1[j-1];
}
ans[i].array1[1]=temp;
ans[i].count++;
}
//This is the part where I'm not so sure
for (int I=1; I<(big2.count-i+1); I++)
{
ans[i].array1[ans[i].count+I]=0;
}
ans[i].count=ans[i].count+(big2.count-i);
ans[0]=ans[0]+ans[i];
}
return (ans[0]);
}