Original Post
Not sure if I am shooting at the wind hear but I am trying to make a simple wrapper for implementation of a 2-D std::vector I am having trouble getting my head around the constructor aspect of this. In order for it to generate the "2nd Demension" I would have to declare a variable like TwoDVector Map(25,25); correct? And I could not simply use the default like so... TwoDVector Map(); If I am correct in my assumption then I would not be able to declare an object of the type TwoDVector inside a .h file. Correct? Any advice would be great Regards Chad
#include <vector>
template <typename T>
class TwoDVector{
public:
TwoDVector(){};
TwoDVector(int rows, int cols):m_data(rows, std::vector<T>(cols)){}
inline std::vector<T> & operator[](int i) { return m_data;}
inline const std::vector<T> & operator[] (int i) const { return m_data;}
void resize(int rows, int cols){
m_data.resize(rows);
for(int i = 0;i < rows;++i) m_data.resize(cols);
}
private:
std::vector<std::vector<T> > m_data;
};