Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- template<typename T>
- class Table {
- private:
- vector<vector<T>> data;
- pair<size_t, size_t> sz;
- public:
- Table(size_t rows, size_t columns) {
- resize(rows, columns);
- }
- vector<T>& operator[](size_t i) {
- return data[i];
- }
- const vector<T>& operator[](size_t i) const {
- return data[i];
- }
- void resize(size_t rows, size_t columns) {
- sz.first = rows;
- sz.second = columns;
- data.resize(rows);
- for (size_t i = 0; i != rows; ++i) {
- data[i].resize(columns);
- }
- }
- pair<size_t, size_t> size() const {
- return sz;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement