Learn C++ With Me #18 - Vectors

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

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

  • @lukaslescinskas4844
    @lukaslescinskas4844 3 года назад +71

    Thank you so much, Tim! This C++ study is the best series from this channel, at least for me. Also more basics of ... could I say, a computer science, would be awesome.

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

      🇱🇹🇱🇹🇱🇹🇱🇹🇱🇹

  • @MrMShady
    @MrMShady 2 года назад +14

    3rd method to iterate throught vector:
    for (auto num : v1)
    cout

  • @minemoi3314
    @minemoi3314 2 года назад +7

    man i was so stuck in a homework and you made me see the light, thank you so much

  • @abrarmasumabir3809
    @abrarmasumabir3809 3 года назад +3

    bro waiting for 21 C++ tutorial ...bring it alive man...you are my hope :)

  • @shamaeelahmed3561
    @shamaeelahmed3561 3 года назад +27

    Could you please continue this series. Your way of teaching is truly amazing

  • @stopbysometimes7590
    @stopbysometimes7590 3 года назад +16

    Hi Tim! Thank you for the vids! I'm a student and its so hard to learn at home but you're making it better for us. Thank you! :D

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

      Tim inspired me to learn and teach coding. And I started my own thanks

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

      But no one will see your programming tutorial when there are youtubers like Tech with Tim who provide high quality content.

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

      @@zombiekiller7101 remember when Tim started there were other great youtubers, before I believe I will be able I just believe

  • @_alfie_phillips_2058
    @_alfie_phillips_2058 3 года назад +43

    I love vectors

  • @gilberthangshing7427
    @gilberthangshing7427 3 года назад +5

    Thank you so much tim for this tutorial. I was just thinking about learning vectors and this video pops up. Could really use this in memory hacking.

  • @souljarohill8795
    @souljarohill8795 2 года назад +14

    Vectors are important. I brushed passed it in CS 2 cause i was so focussed on pointers and still am cause pointers are a beast lol. However, its something I'm taking more time in and learning because the fact is when you do a lot of these hackerank assessments or leetcode problems. Vectors are what you need to know to solve the problems. I was so confused when first trying some problems because I had the right mindset but an array wont cut it. Its as you said, regular arrays are good for when you know what you need. it has to have a static and constant size. Which is good in theory for a lot of problems but the problem is there a lot it isnt good enough as well

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

    A different method to insert:
    int main()
    {
    std::vector v1 = { 1, 2, 3, 4 };
    std::vector::iterator it = v1.begin();
    std::advance(it, 2);
    v1.insert(it, 5);
    std::cout

    • @1-__ISA__-1
      @1-__ISA__-1 8 месяцев назад

      Thank you so much!

  • @ritchielrez1680
    @ritchielrez1680 3 года назад +4

    I thought you only make python tutorials, but now this!!

  • @zkierkniekjion4381
    @zkierkniekjion4381 6 месяцев назад

    This is a really good quick catch up!

  • @torishi82
    @torishi82 9 месяцев назад

    Good summary, short and sweet. Thanks.

  • @divijagarwal8594
    @divijagarwal8594 3 года назад +21

    We can insert a value in a vector directly by knowing its index. Like for a vector v1 -> v1[0] = 2;

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

      @Peterolen oh ok, Thanks for telling :)

    • @justin-ju4eo
      @justin-ju4eo 3 года назад

      @@DRKongo-vi8ok i think he was replying to someone that deleted their comment

    • @shreyas_._
      @shreyas_._ 3 года назад

      @@justin-ju4eo you should watch the full video

    • @Musava
      @Musava 2 года назад +11

      That overrides what is currently there, doesn't insert it into that position?

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

      that wouldn't be an insertion, it would be replacing what is currently at v1[0]

  • @малосольные-окурки
    @малосольные-окурки 10 месяцев назад

    simple and useful. great. thank you!

  • @dususbakahyahskahwbwm9113
    @dususbakahyahskahwbwm9113 8 месяцев назад

    Hey Tim, your videos have been a great help! Thank you. I seen that during the vid you were looking at your notes to ensure which functions to utilize for the code. Would you mind sharing the source of the information you use for your code and your c++ tutorials in general?

  • @emodat08
    @emodat08 3 года назад +9

    You are awesome Tim but could you do an algorithms C++ series after this.

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

    Perfect as always
    Thanks, Tim.

  • @theblock9221
    @theblock9221 Год назад

    Very useful thank you very much you explained it really well

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

    Great Vid, Thanks!

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

    really helpful, thank you.

  • @almirf3729
    @almirf3729 Год назад

    Awesome explanation, thanks

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

    Thanks Tim!

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

    You could use short hand for loop to iterate over collections

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

    thank you!

  • @harshdevmurari007
    @harshdevmurari007 Год назад

    great one...

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

    Thank you, very helpful!

  • @manipurihunabopa
    @manipurihunabopa Год назад

    So here you discuss about the one dimensional array of vectors right? But I wonder if there're any two dimensional vector arrays.

  • @znedj
    @znedj 5 месяцев назад

    Thanks.

  • @mikmik3965
    @mikmik3965 Год назад

    you can offset the v1.begin() +( actual place you want insert ) like this :v1.insert(v1.begin()+5,1111));

  • @killershark90
    @killershark90 2 месяца назад

    so at 4:45 instead of getting the 8 to 16 kind of thing, my size was 10 and my capacity was 13.... really weird... and it started at 4, then 9, then 13 and when the size is 14 the capacity is 19 so weird.

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

    great video tips

  • @bottomlinesabotage
    @bottomlinesabotage 6 месяцев назад

    Is it just me that immediately thinks ‘OHHH YEAAHHH!’ when vectors are mentioned anywhere?

  • @trithanh9967
    @trithanh9967 Год назад

    thank a lot

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

    v1[2] = 6; to assign a (new) value to index 2 of v1

  • @hitthatrwnoflare9645
    @hitthatrwnoflare9645 Год назад +3

    you can also iterate through a vector using, for example:
    for(int i : [vector name]) {}
    this will iterate through the vector, and will automatically assign i the value at the place in the vector

  • @yoyoyo-hw2lc
    @yoyoyo-hw2lc 6 месяцев назад

    Thank you for the video. "vector.pop_back" does not return the element that was removed.

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

    Hi great vid👍, what kind of IDE you use for C++ in this video?

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

      I think its sublime text

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

    So basically I can use vector instead of static array, cool

  • @Sagginn1
    @Sagginn1 Месяц назад

    which compiler are you using?

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

    what text editor is tim using in this vid

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

    So what's the difference between vector x(size) and int *x = new int[size]. If you where you where to only set the amount of space needed once and not change it both would essentially do the same but is one better?

    • @ahmed-elrefai
      @ahmed-elrefai Год назад

      they are basically the same but just dynamic arrays use built in language feature but vectors are a separate library or a class that is made with c++ with some functions that makes life easier so you don't have to reinvent the wheel every time.

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

    bro how do you know so many things and able to make videos on each. So you must have a good understanding of these.

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

    Does v1.insert(v1.at(0), 5) would work?

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

    Thank you so much,

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

    if I type vector v1, what does it mean?

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

      makes a 2d vector
      ex: v1={{1, 2}, {2, 3}}

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

    C++ should be having a standard linear algebra module

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

    What does the auto iteration
    Is it another way of iterating through a vector.

  • @huseynehmedov5255
    @huseynehmedov5255 2 месяца назад

    what is your compiler bro?

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

    Txs Tim. but what tool do you use that compile in 8s. very fast. can you send me

  • @joshuadodo3488
    @joshuadodo3488 9 месяцев назад +1

    What ide are you using please?

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

    do you need to use encapsulation on vectors if they are in class?

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

    Hello Tim, I have a question.
    How long does it take to me after I learned kotlin to program a dating app with it?

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

    how can we sort vector and print it??

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

    What code editor you're using?

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

    How this guy knows so many programming languages 🤔

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

    When is part 2 comming out for typibg race clone?

  • @tanhnguyen2025
    @tanhnguyen2025 Год назад

    I have several questions that needs answering:
    1) I dont understand the part where inside the for loop that iterates through the vector container, you define the auto itr = v1.begin() and when you ran the program, the compiler error popped up and you said you had to dereference the pointer. How do u know it is a pointer ?
    2) can I apply this method of insert and erase function in C++98? or do i need to update it to the latest version of C++ ?
    Overall, your C++ tutorial video is incredibly amazing and I really appreciate the amount of effort you've put into making this video. Thank you dude !

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

    [Error] in C++98 'my_vector' must be initialized by constructor, not by '{...}'

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

    Can you start a tutorial on ethical hacking

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

    Hey tim, will you ever learn quantum computing languages?

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

      Oh wow did ur clg teach that to u?

  • @joeboehaha
    @joeboehaha 10 месяцев назад

    This dude have very less subscriber feeling bad 😢

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

    Hello, for a non-English speaker, you speak too quickly. However, the content is perfect!

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

    what is your IDE?

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

    Capacity is only increasing. The same as taxes...

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

    3rd commenter and 40th viewer

  • @clashersamir1625
    @clashersamir1625 Год назад

    bruh just uploaded video on yt without any preparation after getting out from washroom...and still getting views.

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

    I do not understand why do you say arrays are inmutable in lenght, I tried to create an array with a defined length from the beggining not letting the array to be undefined in lenght and it perfectly lets you add however items you want...

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

    🔥🔥🔥🔥🔥🔥🔥Can h please make the code on VS Code please 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🎉🔥🔥🔥🔥🔥🎉

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

    mark

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

    :)

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

    I didn't understand nothing about this lesson

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

    you shouldn't teach people to use namespace std... especially not in tutorials for beginners. Using this namespace is one of the most common sources for errors and bugs and its so easy to avoid

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

    In the beginning I don’t understand why the output was 16 I understand the output 9 but not 16 where did the 16 come from

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

      In vector, the capacity will double if a new element is added. so first, after the capacity exceeds 4, it becomes 8. And when he added more values, when the capacity exceeds 8 it'll just get doubled. So it is 16!

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

    I can't believe you've built a successful RUclips channel based on stuf that's easily found on the web lol

    • @Dcookies100
      @Dcookies100 2 года назад +5

      some people just want stuff in a video format instead of reading it, not a big deal considering so many channels similar to this exist.
      Even bootcamps that cost thousands of dollars just get their stuff off of the internet :p