In this case, a simple constructor will work:
foo(int x, int y) : x(x), y(y) {}
If the class was an even simpler aggregate (which you would have if the data members were publicly available), then you do not even need to - this initialization style will initialize each member of the aggregate in turn.
- , vector, , initializer_list. :
#include <initializer_list>
foo(std::initializer_list<int>);
, begin(), end() size() .