[求助]老是说xalloc没声明
#include <iostream>
#include <cerrno>
using namespace std;
template<class T>
void ChangeSize1D(T *&x,int size,int Tosize)
{
T * NewX =new T[Tosize];
for(int i = 0;i < size; ++i)
NewX[i] = x[i];
delete []x;
x = NewX;
}
int main()
{
float *x;
try{x = new float[3];}
catch(xalloc){
cerr<<"Out of Memory"<<endl;
exit(1);
}
try{ChangeSize1D(x,3,5);}
catch(xalloc)
{
cerr<<"Could bot create x"<<endl;
exit(1);
}
x[4] = 4;
cout<<x[4]<<endl;
delete []x;
system("pause");
return 0;
}
d:\c++练习\cpp1.cpp(17) : error C2061: syntax error : identifier 'xalloc'