If I have a templated storage class, how can I create a specialized template for nested storage class. I already know how to specialize pointer template, but I don't know how to specialize this. EG:

template <typename Type>
class Array
{
///Array class code
};
int main()
{
    Array<int> rob;
    Array<Array<int> > bob;//I need bob to be specialized, but not rob
    return 0;
}

Is this possible?

You can still use the template parameter for a nested type:

#include <iostream>

template <typename Type>
class Array {
public:
    Array() { std::cout<<"Default Array<>\n"; }
};

template <typename Type>
class Array<Array<Type> > {
public:
    Array() { std::cout<<"Specialized Array<>\n"; }
};

int main()
{
    Array<int> rob;
    Array<Array<int> > bob;
}

It only gets tricky if you need to generalize both parameter types (vector instead of Array, and double instead of int, for example).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.