Pages

Saturday, April 26, 2025

Vector Implementation in Memory in C++

#include <iostream>

#include <vector>

using namespace std;


int main()

{

    vector<int> vec;

    cout << "size : " << vec.size() << endl;

    cout << "capacity : " << vec.capacity() << endl;

       

    

    

    vec.push_back(4); // changes vec size to 4

    cout << "size : " << vec.size() << endl;

    cout << "capacity : " << vec.capacity() << endl; // 8 (double of 4)

    

    vec.pop_back(); // size resets

    cout << "size : " << vec.size() << endl;

    cout << "capacity : " << vec.capacity() << endl;

    return 0;

    

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...