Wednesday, February 11, 2015

C++ Tutorial for Beginners 44 - C++ Vectors









1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <vector>
#include <algorithm>    // std::remove
using namespace std;

int main()
{
std::vector<int> my_vec;
my_vec.push_back(10);
my_vec.push_back(20);
my_vec.push_back(30);
my_vec.push_back(40);

cout << "vector size = "<< my_vec.size() << endl;

for (int i=0;i< my_vec.size();i++)
     cout << "vector " <<i <<"  "<< my_vec.at(i) << endl;

   ///my_vec.erase(my_vec.begin() + 3);
   /// my_vec.erase(std::remove(my_vec.begin(),my_vec.end(),30),my_vec.end());
   ///   my_vec.clear();
     cout << endl<< endl;
  //my_vec.resize();
  cout << "is vector empty = "<< my_vec.empty() << endl;

  for (int i=0;i< my_vec.size();i++)
     cout << "vector " <<i <<"  "<< my_vec.at(i) << endl;

return 0;
}




















vector::vector - C++ Reference

C++ Tutorial: A Beginner's Guide to std::vector

The STL Vector Class

Searches related to c++ vector

Sequence container (C++)

c++ vector initialization

c++ vector to array

c++ vector of pointers

c++ vector assign

c++ vector contains

c++ vector example

c++ vector of objects

c++ vector push_bac





C++ , STANDARD TEMPLATE LIBRARY (STL)

C++ STL ( Standard Template Library) Tutorial - Learning C++ in simple and easy steps : A beginner's tutorial containing complete knowledge of C++ Syntax Object Oriented Language, Methods, Overriding, Inheritance, Polymorphism, Interfaces, STL, Iterators, Algorithms, Exception Handling, Overloading,Templates, Namespaces and Signal Handling
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ