tags:

views:

121

answers:

4
vector<int> ivec(4, 3);

can anyone pls explain me the above? I'm newbie & try to learn the c++.

Thanks

+1  A: 

Sorry to be flippant but: http://www.cplusplus.com/reference/stl/vector/

graham.reeds
+1: A good reference.
S.Lott
-1 for giving a link merely.
equilibrium
The 3 questions he has asked so far have all been answerable by a simple search on Google or looking at the above reference site.
graham.reeds
+6  A: 

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.

Prasoon Saurav
+1  A: 

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:

bua
+3  A: 
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

DumbCoder