Skip to content

Instantly share code, notes, and snippets.

@Ben1980
Last active November 9, 2019 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ben1980/294e99c13124aa8517c0d1076bdbdb1d to your computer and use it in GitHub Desktop.
Save Ben1980/294e99c13124aa8517c0d1076bdbdb1d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
void print(const std::vector<std::vector<int>> &vec) {
std::cout << "sizeof(int): " << sizeof(int) << '\n';
std::cout << "sizeof(std::vector<int>(10)): " << sizeof(std::vector<int>(10)) << '\n';
for(const auto & r : vec) {
std::cout << "Row address: " << &(r) << '\n';
for(const auto & c : r) {
std::cout << &(c) << ", ";
}
std::cout << '\n';
}
std::cout << std::endl;
}
int main() {
std::vector<std::vector<int>> vec = { {0,1,2,3,4,5,6,7,8,9,10},
{0,1,2,3,4,5,6,7,8,9,10},
{0,1,2,3,4,5,6,7,8,9,10} };
print(vec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment