Use template to dynamic allocate complex type in C++ ???

I have some function, but don't know dynamic allocate complex array. Please guide to me.
This is my source C++:

#include<iostream>
using namespace std;
template <class T,class U)
T *allocate1D(U nx){
T *arr=new T[nx];
return arr;
}
int main(){
int nx,i,tmp1,tmp2;
nx=2;tmp1=1;tmp2=2;
complex<float> *cp;
cp=allocate1D<complex<float>>(nx); // ????? Do?
for(i=o;i<nx;i++)
cp[i]=complex<float> (tmp1++,tmp2++);
cerr<<"Print to Screen"<<endl;
for(i=o;i<nx;i++)
cerr<<"-- Real: '<<cp[i].real()<<" --Image: "<<cp[i].imag()<<" -- Num: "<<cp[i]<<endl;
return 0;
}

Thanks!
Topic archived. No new replies allowed.