{
T *elements;
int last;
int maxsize;
fstream datafile;
public:
Array(int max=10);
~Array();
void enlarge(int);
void insert (T& data,int i);
friend ostream &operator<<(ostream &dist,Array &ar)
{
int i;
if(ar.last=-1)
{
cout<<"empty list!"<
}
else
{
for(i=0;i<=ar.last;i++)
dist<
}
}
};
template
{
last=-1;
maxsize=max;
elements=new T[maxsize];
datafile.open("datafile.txt",ios::in);
if(!datafile==0)
{
while(!datafile.eof())
{
datafile>>*(elements+last+1);
last++;
}
datafile.close();
}
datafile.clear(0);
}
template
{
int i;
datafile.open("datafile.txt",ios::out);
for(i=0;i<=last;i++)
datafile<
datafile.clear(0);
delete[]elements;
elements=NULL;
}
class Complex
{
private:
int x , y;
public:
Complex(int a=0,int b=0)
{
x=a;
y=b;
}
friend ostream &operator <<(ostream &dist,Complex & a)
{
dist<
}
friend istream &operator >>(istream &dist ,Complex &a)
{
dist>>setw(10)>>a.x>>" ">>a.y>>setw(10);
return dist;
}
};
void main()
{
Array
//据,若是首次创建(无历史数据文件),则不赋值
cout<double r, i;
cout<<"请输入3个复数的实部虚部:";
for(int j=0;j<3;j++)
{ cin>>r>>i;
Complex c(r,i);
a.insert(c, j);
}
cout<} //程序退出时数据应写入文件