Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to free the vector c++

// CPP program to illustrate
// Implementation of clear() function
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    vector<int> myvector;
    myvector.push_back(1);
    myvector.push_back(2);
    myvector.push_back(3);
    myvector.push_back(4);
    myvector.push_back(5);
 
    // Vector becomes 1, 2, 3, 4, 5
 
    myvector.clear();
    // vector becomes empty
 
    // Printing the vector
    for (auto it = myvector.begin(); it != myvector.end(); ++it)
        cout << ' ' << *it;
    return 0;
}
//Output: No Output since vector gets empty
Comment

PREVIOUS NEXT
Code Example
Cpp :: Write C++ program to copy one string to another string using pointers 
Cpp :: c++ vector element search 
Cpp :: math in section title latex 
Cpp :: remove element from vector on condition c++ 
Cpp :: retu7rn this c++ 
Cpp :: how to make a hello world program in c++ 
Cpp :: minimum and maximum value of a vector in C++ 
Cpp :: fork c 
Cpp :: c++ read integers from file 
Cpp :: c++ rule of five 
Cpp :: how to declare 1-D array in C/C++ 
Cpp :: c++ string remove first character 
Cpp :: c++ lock 
Cpp :: how to iterater map of sets in c++ 
Cpp :: default access modifier in c++ 
Cpp :: c++ extend class 
Cpp :: syntax c++ 
Cpp :: appending int to string in cpp 
Cpp :: c++ type casting 
Cpp :: What should main() return in C++? 
Cpp :: int_max cpp 
Cpp :: fstring from float c++ ue4 
Cpp :: c++ multidimensional vector 
Cpp :: How to pause a c++ program. 
Cpp :: aray of functions in c++ 
Cpp :: min element in stl c++ 
Cpp :: c++ remove numbers from vector if larger than n 
Cpp :: how to delete a file in cpp 
Cpp :: why is using namespace std a bad practice 
Cpp :: filling 2d array with 0 c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =