Reputation: 1267
I am trying to use an open source class whose .h file starts with:
template <class DT>
class FFTReal
{
public:
enum { MAX_BIT_DEPTH = 30 };
typedef DT DataType;
explicit FFTReal (long length);
...
my first creating a pointer to the class in my private section of my class:
ffft::FFTReal<double> *m_fft_object;
And then, within an initialization function, create it with
m_fft_object = new fft_object((long)(FFTWindowSize));
It is in this last line that I get the error "Error:expected a type". I have done some searches for the error but nothing seems to match my particular problem.
Thanks
Upvotes: 0
Views: 1830
Reputation: 169008
Presumably this is because fft_object
is not a type. You probably meant this:
m_fft_object = new ffft::FFTReal<double>(static_cast<long>(FFTWindowSize));
I also corrected the C-style cast for you.
As noted in the comments, you should avoid using raw pointers to store object data unless you have a very good reason. Consider using a smart pointer (std::unique_ptr<ffft::FFTReal<double>>
) if the data should be nullable, otherwise you can simply store an object instance as a value (ffft::FFTReal<double>
). Either option will make memory leaks extremely unlikely, whereas when using new
and raw pointers you have to be extremely careful to delete the allocated object when you are done with it.
Upvotes: 4