Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

initialize a vector pf points in C++

Point P0(0,0), P1(3, 4), P2(-50,-3), P3(2,0); //Input  Points (fine)
std::vector<Point>  Points(P0,P1, P2 ,P3); (not fine)

This does not seem to work. How do I initialize points vector to the values above? Or is there an easier way to do this?

like image 536
Programmer Avatar asked Dec 28 '25 17:12

Programmer


1 Answers

If you are using c++11, you can use braces to declare vectors inline.

std::vector<Point> Points {P0, P1, P2, P3};
like image 93
Red Alert Avatar answered Dec 31 '25 07:12

Red Alert