Last active
September 28, 2018 21:15
-
-
Save kylemsguy/bc464fb32aa982844ba34be664979efd to your computer and use it in GitHub Desktop.
Vector of Vectors test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
class Blah { | |
private: | |
int a; | |
public: | |
Blah(int a){ | |
this->a = a; | |
} | |
int get_a(){ | |
return this->a; | |
} | |
}; | |
void print_blahs(vector<vector<Blah> > blahs){ | |
for(int i = 0; i < blahs.size(); i++){ | |
for(int j = 0; j < blahs[i].size(); j++){ | |
printf("%d\t", blahs[i][j].get_a()); | |
} | |
printf("\n"); | |
} | |
} | |
int main(int argc, char **argv){ | |
vector<vector<Blah> > *array = new vector<vector<Blah> >(); | |
for(int i = 0; i < 5; i++){ | |
vector<Blah> *row = new vector<Blah>(); | |
for(int j = 0; j < 5; j++){ | |
row->push_back(Blah(i+j)); | |
} | |
array->push_back(*row); | |
} | |
print_blahs(*array); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment