theres multiple problems here. for one, a 2d array is not the same thing as a pointer-to-pointer. also, you cannot implicitly size static arrays of more than one dimension.
the closest you could come to what you're after is using implicit conversion, like so:
Code:
template<typename T>
class Mat{
public:
template<unsigned int Rows,unsigned int Columns>Mat(const T(&data)[Rows][Columns]):
rows(Rows),
columns(Columns),
mem(new T[Rows*Columns])
{
memcpy(mem,data,sizeof(T)*Rows*Columns);
}
~Mat()
{
delete[] mem;
}
const unsigned int rows;
const unsigned int columns;
T& operator()(unsigned int row,unsigned int column)
{
return mem[row*columns+column];
}
const T& operator()(unsigned int row,unsigned int column)const
{
return mem[row*columns+column];
}
private:
T *mem;
};
int _tmain(int argc, _TCHAR* argv[])
{
int data[][3] = {{1,2,3}, {2,3,4}};
Mat<int> a = data;
for(unsigned int row = 0; row < a.rows; ++row)
{
for(unsigned int column=0; column < a.columns; ++column)
{
std::cout << a(row,column) << '\t';
}
std::cout << '\n';
}
std::cin.get();
}
i wouldn't recommend doing it this way personally, but here it is.