#AL.hpp
template <typename A>
class AL
{
public:
void print(A *source, A *dest, unsigned int size);
private:
A *data;
unsigned int size;
unsigned int capacity;
}
namespace {
template <typename A>
unsigned int size s_size = 20;
void print(A *source, A *dest, unsigned int size)
{
....
}
}
template <typename A>
AL<X>& AL<X>::push(A input)
{
capacity *= 2;
A *new_data = new A[capacity];
print(data, new_data, size);
}
I am just wondering how to format this (please don't mind the code). When I run my full code, it says that A is not defined in the namespace. I'm not sure how to pass in the class template to my namespace.
namespacetemplated? Or the functionprint? Because you can't make templated namespaces. If you want a templated "namespace" you have to make astructwith only static members.templatedeclaration for the function (or rather, it's not atemplatedeclaration for the function, but for the variable declaration, which itself is not valid).