i wanted to create a template class with a static function
template <typename T>
class Memory
{
public:
template < typename T>
static <T>* alloc( int dim )
{
T *tmp = new T [ dim ];
return tmp;
};
}
but i will always get
int *a = Memory::alloc<int>(5)
i dont know what to chance..
»template<class T> class Memory« used without template parameters
expected primary-expression before »int«
Fehler: expected »,« or »;« before »int«
You’re templating both the class and the function, when you likely only want to template one of them.
Is this what you mean?
Here’s a correct version with both:
You can remove the outer template if you just want the function to be templated.