Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <class T>
- class vector2D
- {
- std::vector<T> m_Field;
- int m_Height;
- int m_Width;
- public:
- int getWidth() const{return m_Width;}
- int getHeight() const{return m_Height;}
- vector2D()
- :m_Field(),
- m_Height(0),
- m_Width(0)
- {
- }
- vector2D(int width, int height)
- :m_Field(width*height),
- m_Height(width),
- m_Width(height)
- {
- }
- void resize(int width, int height)
- {
- m_Width = width;
- m_Height = height;
- m_Field.resize(m_Width*m_Height)
- }
- T& at(int x, int y)
- {
- return m_Field.at(m_Width*vector.y+vector.x);
- }
- const T& at(int x, int y) const
- {
- return m_Field.at(m_Width*vector.y+vector.x);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement