// Code mostly from http://www.codeguru.com/forum/showthread.php?s=&threadid=231046
// CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ FAQS > STL: How to declare and use two-dimensional arrays?
// Author: Yves M

#include <vector>

using namespace std;

template <typename T> class Dynamic2DArray
{
private:
	std::vector< std::vector<T> > data;

public:
	Dynamic2DArray() {};
	Dynamic2DArray(int rows, int cols)
	{
		for (int i=0; i<rows; i++)
			data.push_back( std::vector<T>(cols) );
	}

	std::vector<T> & operator[](int i)
	{
		return data[i];
	}
	const std::vector<T> & operator[](int i) const
	{
		return data[i];
	}

	void resize(int rows, int columns)
	{
		data.resize(rows);
		for (int i=0; i<rows; i++)
			data[i].resize(columns);
	}

};