fork download
#include <vector>
#include <iostream>

class Vector
{
public:
  float x,y;
};

int main()
{    
  // uninitialized grid[0] and grid[1]
  std::vector<Vector> grid(2);
  
  // (5, 3) stored in grid[2]
  // element constructed directly in "grid"
  grid.emplace_back(Vector{5.f, 3.f}); 
  
  std::cout << grid[2].x << "," << grid[2].y << '\n';
  return 0;
}
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
5,3