Vector | C++ STL (Standard Template Library) | std::vector

Поделиться
HTML-код
  • Опубликовано: 8 ноя 2024

Комментарии • 19

  • @ayyappahemanth7134
    @ayyappahemanth7134 4 года назад +4

    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.

  • @hieuhuynh2320
    @hieuhuynh2320 2 года назад +2

    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.

    • @KnowledgeCenter
      @KnowledgeCenter  2 года назад

      Thanks. You are welcome to suggest topics for videos.

  • @mahadifamgate2686
    @mahadifamgate2686 3 года назад +2

    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.

  • @rahuldubey65
    @rahuldubey65 4 года назад +1

    Excellent explanation sir. u cleared all doubts by using different examples. Thanks a lot👌

  • @rickzhi5498
    @rickzhi5498 Год назад +1

    Thank you very much, sir

  • @javiereduardojimenezquiten2714
    @javiereduardojimenezquiten2714 2 года назад +1

    Awesome video, great explanation, keep the good work.

  • @jvsnyc
    @jvsnyc 3 года назад +1

    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.

    • @RIPNANI
      @RIPNANI 3 месяца назад

      😅

  • @jvsnyc
    @jvsnyc 3 года назад

    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.

    • @RIPNANI
      @RIPNANI 3 месяца назад

      😅

  • @moisesdepaulodias7980
    @moisesdepaulodias7980 2 года назад +1

    very good, thank you very much

  • @charansashidhar2214
    @charansashidhar2214 4 года назад

    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

    • @jvsnyc
      @jvsnyc 3 года назад

      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.