i'm new to C++ and programming in general, plus english isn't my first language so I might have trouble phrasing my question correctly for you to understand.
I wrote the following, working, program :
#include<iostream> #include<vector> using namespace std; class Vector{ vector<int>numbers; public: Vector(vector<int> const& v) : numbers(v) {} void print(){ for (const auto& elem : numbers){ cout << elem << " "; } } }; int main(){ Vector p{ vector < int > {15, 16, 25} }; p.print(); } Now if I try to create an object writing:
Vector p{ 15, 16, 25 }; it doesn't work. My question is what do I have to do in order for it to work? Help would be much appreciated! Thanks in advance.