fork(2) download
  1. #include <vector>
  2. #include <iostream>
  3.  
  4. using foo = std::vector<double>;
  5.  
  6. int main()
  7. {
  8. std::vector<foo> Vfoo(3);
  9.  
  10. Vfoo[0].resize(20);
  11. Vfoo[1].resize(1);
  12.  
  13. for ( unsigned i = 0; i<20; ++i)
  14. Vfoo[2].push_back(3.14*i) ;
  15.  
  16. std::cout << "Vfoo[0]:\n";
  17. std::cout << "\tsizeof = " << sizeof(Vfoo[0]) << '\n' ;
  18. std::cout << "\telements stored = " << Vfoo[0].size() << '\n' ;
  19. std::cout << "\tcapacity = " << Vfoo[0].capacity() << "\n\n" ;
  20.  
  21. std::cout << "Vfoo[1]:\n";
  22. std::cout << "\tsizeof = " << sizeof(Vfoo[1]) << '\n' ;
  23. std::cout << "\telements stored = " << Vfoo[1].size() << '\n' ;
  24. std::cout << "\tcapacity = " << Vfoo[1].capacity() << "\n\n" ;
  25.  
  26. std::cout << "Vfoo[2]:\n";
  27. std::cout << "\tsizeof = " << sizeof(Vfoo[2]) << '\n' ;
  28. std::cout << "\telements stored = " << Vfoo[2].size() << '\n' ;
  29. std::cout << "\tcapacity = " << Vfoo[2].capacity() << '\n' ;
  30. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
Vfoo[0]:
	sizeof = 12
	elements stored = 20
	capacity = 20

Vfoo[1]:
	sizeof = 12
	elements stored = 1
	capacity = 1

Vfoo[2]:
	sizeof = 12
	elements stored = 20
	capacity = 32