How to overload the new operator for std::complex<double>?

P

PengYu.UT

Hi,

In FFTW (http://www.fftw.org/), it defines the funciton fftw_malloc to
allocate memory properly aligned.

However, I only want to use new to allocate memory for
std::complex<double>. Can some body show me how to redefine the new
operator for an class already defined in the library?

Thanks,
Peng
 
M

Mike Wahler

Hi,

In FFTW (http://www.fftw.org/), it defines the funciton fftw_malloc to
allocate memory properly aligned.

However, I only want to use new to allocate memory for
std::complex<double>.

std::complex<double> *p = new std::complex<double>;
/* do stuff with the object */
delete p;
Can some body show me how to redefine the new
operator for an class already defined in the library?

You don't need to redefine 'new'.

BTW why do you feel you need to dynamically allocate
your object(s) anyway?

-Mike
 
P

PengYu.UT

/* do stuff with the object */
delete p;

I was asking how to redefine the "new" operator, such that when I call
BTW why do you feel you need to dynamically allocate
your object(s) anyway?

For example, the array is defined in an class, and its size is not
fixed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top