I'm having some problem with dynamic allocation of templates. My code contains a template class with a function that creates a new instance of the class, like this:
Yes, I've only included the class declaration and function definition otherwise there'd be lots more code. With hindsight I should probably have commented it as well.
Ok, after playing around I've discovered the error is due to declaring an array of the template class. So now it all boils down to, how do you declare an array objects from a class template?
As std::vector<T> or std::deque<T> or std::valarray<T>, where the vector is preferred for substitution of old-style ("C-Style") arrays by the standard.
But that doesn't solve the problem of why it's failing to construct an array of objects.
Let's see the constructor.
Also, the call stack would be useful in determining how deep in the recursion it went.
On a different note, replace pow((double)-1,j) with 1/j. 1.0/float(j), if you must, but don't call pow().