Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

C++ Vector Operation Delete Elements

#include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> num{1, 2, 3, 4, 5};
  
  // initial vector
  cout << "Initial Vector: ";
  for (int i : num) {
    cout << i << " ";
  }

  // remove the last element
  num.pop_back();

  // final vector
  cout << "
Updated Vector: ";
  for (int i : num) {
    cout << i << " ";
  }
  
  return 0;
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Vector #Operation #Delete #Elements
ADD COMMENT
Topic
Name
9+5 =