I'm purely a python programmer. Now I can see that c++ was also easy to learn after that. Please do more and more I am willing to learn after watching this video.
This course is really detail and easy to understand. Hope Knowledge Center channel will have more useful video with excellent explanation like this. Thank you so much.
i found very helpful, i tried books for STL , felt difficult there,,,, your representation is easy,,, a very good chanel i just found.... many thank you.
I've seen people attacking C++ as unsafe, because [] without range check can cause Undefined Behavior. Well, that is why you have the option to use at(). If you use the very easy syntax of [ ] for indexing, you had best be sure that your index is valid, if you switch to using at() you could instead catch the out_of_range exception, for instance, if you are *almost sure* that your index is good, but don't want to chance the dreaded Undefined Behavior. Also, note that calling front() or back() on an empty vector also strays into Undefined Behavior. So...don't do that.
When checking if empty() or not, it is an optimization with many containers to call that instead of comparing size() to 0, because they may not know their size at all times, and might go thru a lot of work to find out the size is, say, 1'000'000, when empty() would return false as soon as it sees there is even 1 element in that container. I don't think it makes much difference for vector, but shows your intent.
what if i erase one of the element does it resize back or does it stay in the previous size lets say size is 3 before erase and after erase does it change
For erase(), the size always definitely goes down, the capacity will not. If you want to reclaim the space you can request a shrink_to_fit() for the vector. For clear(), the size goes to zero, but again, it doesn't touch the capacity unless you specifically request that afterwards.
I'm purely a python programmer. Now I can see that c++ was also easy to learn after that. Please do more and more I am willing to learn after watching this video.
This course is really detail and easy to understand. Hope Knowledge Center channel will have more useful video with excellent explanation like this. Thank you so much.
Thanks. You are welcome to suggest topics for videos.
i found very helpful, i tried books for STL , felt difficult there,,,, your representation is easy,,, a very good chanel i just found.... many thank you.
It's my pleasure
Excellent explanation sir. u cleared all doubts by using different examples. Thanks a lot👌
👍
Thank you very much, sir
Welcome!
Awesome video, great explanation, keep the good work.
Thanks!
I've seen people attacking C++ as unsafe, because [] without range check can cause Undefined Behavior. Well, that is why you have the option to use at(). If you use the very easy syntax of [ ] for indexing, you had best be sure that your index is valid, if you switch to using at() you could instead catch the out_of_range exception, for instance, if you are *almost sure* that your index is good, but don't want to chance the dreaded Undefined Behavior. Also, note that calling front() or back() on an empty vector also strays into Undefined Behavior. So...don't do that.
😅
When checking if empty() or not, it is an optimization with many containers to call that instead of comparing size() to 0, because they may not know their size at all times, and might go thru a lot of work to find out the size is, say, 1'000'000, when empty() would return false as soon as it sees there is even 1 element in that container. I don't think it makes much difference for vector, but shows your intent.
😅
very good, thank you very much
Welcome.
what if i erase one of the element does it resize back or does it stay in the previous size
lets say size is 3 before erase and after erase does it change
For erase(), the size always definitely goes down, the capacity will not. If you want to reclaim the space you can request a shrink_to_fit() for the vector. For clear(), the size goes to zero, but again, it doesn't touch the capacity unless you specifically request that afterwards.