You could use template specialization for this:
template<int size, class Type>
class Array {
// General stuff for size > 2, if you have any
};
template <class Type>
class Array<1, Type>
{
// Code for one-dimensional array
};
template <class Type>
class Array<2, Type>
{
// Code for two-dimensional array
};
or even specify it for int exactly:
template <>
class Array<2, int>
{
// Code for two-dimensional integer array
};
It is also perfectly valid for them to have totally different set of public interfaces.
But I would probably pass an array or std::vector
of given size for dimensions or remove the third argument, just add a method, say, populate(Type t)
to do the trick (and it may be also useful not only for constructing).