STL vector (Relationship between Static array, Dynamic array and STL vector) with examples

preview_player
Показать описание
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
It is a powerful, secure text editor designed specifically for programmers.

However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇

In this course, you'll learn about the relationship between STL Vector, Static array and Dynamic array.
You'll learn the most important characteristics of each, their advantages and disadvantages, and examples of when to use them.
I'll also show you how to work with STL Vector, access, insert and delete elements from a specific position inside STL vector, what are iterators and constant iterators, examples, use-cases, and all other important STL Vector functionalities.

Contents:
00:00 - What you'll learn in this video
00:46 - Best VS plug-in for C/C++ dev
02:14 - Static arrays (characteristics, advantages, limitations, examples)
06:43 - Dynamic arrays (characteristics, advantages, limitations, examples)
08:29 - What is STL vector
09:50 - Working with STL vector (important functionalities)
25:37 - STL vector vs Dynamic Array vs Static Array

Other videos to watch:

Follow me on other platforms:
Рекомендации по теме
Комментарии
Автор

📚 Learn how to solve problems and build projects with these Free E-Books ⬇
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

Code from the video:

#include<iostream>
#include<vector>
using namespace std;



void main() {

vector<int>numbers;
//numbers.push_back(0);



for (int i = 1; i <= 10; i++)
numbers.push_back(i);



//1. print vector elements
//for (int n : numbers)
// cout << n << endl;



//2. print vector elements with iterators
for (auto it = numbers.begin(); it != numbers.end(); it++) {
//cout << it << endl;
cout << *it << endl;
cout << &it << endl;
cout << &(*it) << endl;
}



auto it = numbers.begin();
cout << "Element at index 5 is: " << *(it + 5) << endl;



//Important functionalities
cout << "Size: " << numbers.size() << endl;
cout << "Max size: " << numbers.max_size() << endl;
cout << "Capacity: " << numbers.capacity() << endl;
numbers.resize(5);
cout << "Size after resizing: " << numbers.size() << endl;
if (numbers.empty())
cout << "Vector is empty" << endl;
else
cout << "Vector is not empty" << endl;
cout << "Element[0] is: " << numbers[0] << endl;
cout << "Element at(0) is: " << numbers.at(0) << endl;
cout << "Front: " << numbers.front() << endl;
cout << "Back: " << numbers.back() << endl;



//insert element at specific position in vector
+ 2, 88);
//erase element from a specific position
+ 2);
//remove last element of vector
numbers.pop_back();



//clear all the elements of vector
numbers.clear();
cout << "Size after clear: " << numbers.size() << endl;


cin.get();
}

CodeBeauty
Автор

Your way of explaining is so practical and easy to understand. I've learned a lot by watching your lessons everyday. Thank you!

heikin
Автор

I'm starting over from 0 and remembering everything I learned at the computer science university I did here in Brazil. I was away for a long time and I encouraged myself to move on, you are really amazing, you are helping me a lot.

andrecorrea
Автор

very helpful, i finaly understand when to use arrays (Static) and when to use vectors. thanks saldina

dundyd
Автор

I was waiting for this video, love it!

nvusb
Автор

Your C++ videos have been a lifesaver. Thanks for making it easy to learn. Any plans to do a video on runtime analysis/optimization?

SDot
Автор

amazing explanation, cleared all my doubts as always

l.p.
Автор

Among many other youtubers that I tried to get help in my C++ learning, you are really the best one! Thank you!

paulkap
Автор

I want to say thank you. I watched all the episodes, it was an amazing adventure. I started with the basics, then functions, pointers and then data structures. I think I am ready for object-oriented programming lessons. I must admit that this will be new to me, but with your help, I am sure I will be able to understand this concept.

JarekAtWork
Автор

I watched all your videos about arrays, dynamic arrays and multidimensional dynamic arrays, so I knew this one is going to be great as well. Thanks Saldina <3

gollygobih
Автор

Oh.. Saldina, you have the best channel of programming in this world. The BEST, now I'm a python/JS programmer but I watch your videos just because your explaining is perfect!
Thanks for this!

cristianomoreira
Автор

this is perfect timing i was just hoping to find a vector video by your great channel

mirahamdan
Автор

thank you for this content, you made it clear to learn and giving out the pros and cons, a lot of thanks❤❤

lickguitars
Автор

Very new to coding, just finished your ten hour coding video on c++, found the diagrams extremely useful and the explanation, this video was useful to, thank you

Pepespizzeria
Автор

Such a lovely and smart young lady! Pure pleasure to watch your videos and learn with your help. Keep going!

yeromin_g
Автор

I love this channel. I learn so much.

pkerr
Автор

Thank you so much Saldina for this amazing tutorial 🥰.I hope you make a video about queue vs stack and their advantages and desadvantegs and which one to use according to the situation.

akosyt
Автор

Thank you so much for starting stl series ❤ 🥰

spanningtree
Автор

your methods are so easy to understand unlike many youtube contents ! Please would you make some videos about Datastructures and some advances search algorithms using C++.I'm sure you can explain it perfectly!

chadidridi
Автор

your videos very useful to me, thank you, keep going

maheshvelugula