vector<int> ivec(4, 3);
can anyone pls explain me the above? I'm newbie & try to learn the c++.
Thanks
vector<int> ivec(4, 3);
can anyone pls explain me the above? I'm newbie & try to learn the c++.
Thanks
Sorry to be flippant but: http://www.cplusplus.com/reference/stl/vector/
vector<int> ivec(4, 3);
defines a std::vector
of 4 integers
each with value 3
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
constructor gets used in this case.
Here you have great reference link for stl.
Vector is here.
From above link:
The third constructor creates a vector with num objects. If val is specified, each of those objects will be given that value, otherwise, those objects are given TYPE's default constructor's value. For example, the following code creates a vector consisting of five copies of the integer 42:
vector<Datatype> c Creates an empty vector without any elements
vector<Datatype> c1(c2) Creates a copy of another vector of the same type (all elements are copied)
vector<Datatype> c(n) Creates a vector with n elements that are created by the default constructor
vector<Datatype> c(n,elem) Creates a vector initialized with n copies of element elem
vector<Datatype> c(beg,end) Creates a vector initialized with the elements of the range [beg,end)
Complete referral from C++ Standard Library: A Tutorial and Reference