Video není dostupné.
Omlouváme se.

Learn C++ With Me #18 - Vectors

Sdílet
Vložit
  • čas přidán 7. 08. 2024
  • Welcome back to another C++ tutorial! In this video, we're going over vectors. Vectors are resizeable arrays that are able to change their size based off of what is inside them.
    💻 AlgoExpert is the coding interview prep platform that I used to ace my Microsoft and Shopify interviews. Check it out and get a discount on the platform using the code "techwithtim" algoexpert.io/techwithtim
    🔍 Playlist: • Learn C++ With Me
    ⭐️ Timestamps ⭐️
    00:00 | Introduction
    00:37 | What Are Vectors?
    01:54 | Creating Vectors
    02:24 | Access Vector Elements
    03:12 | Common Vector Methods and Capacity
    08:21 | Insert and Erase Elements
    10:49 | Iterating Through Vectors
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    💰 Courses & Merch 💰
    💻 The Fundamentals of Programming w/ Python: tech-with-tim.teachable.com/p...
    👕 Merchandise: teespring.com/stores/tech-wit...
    🔗 Social Medias 🔗
    📸 Instagram: / tech_with_tim
    📱 Twitter: / techwithtimm
    ⭐ Discord: / discord
    📝 LinkedIn: / tim-ruscica-82631b179
    🌎 Website: techwithtim.net
    📂 GitHub: github.com/techwithtim
    🔊 Podcast: anchor.fm/tech-with-tim
    🎬 My CZcams Gear 🎬
    🎥 Main Camera (EOS Canon 90D): amzn.to/3cY23y9
    🎥 Secondary Camera (Panasonic Lumix G7): amzn.to/3fl2iEV
    📹 Main Lens (EFS 24mm f/2.8): amzn.to/2Yuol5r
    🕹 Tripod: amzn.to/3hpSprv
    🎤 Main Microphone (Rode NT1): amzn.to/2HrZxXc
    🎤 Secondary Microphone (Synco Wireless Lapel System): amzn.to/3e07Swl
    🎤 Third Microphone (Rode NTG4+): amzn.to/3oi0v8Z
    ☀️ Lights: amzn.to/2ApeiXr
    ⌨ Keyboard (Daskeyboard 4Q): amzn.to/2YpN5vm
    🖱 Mouse (Logitech MX Master): amzn.to/2HsmRDN
    📸 Webcam (Logitech 1080p Pro): amzn.to/2B2IXcQ
    📢 Speaker (Beats Pill): amzn.to/2XYc5ef
    🎧 Headphones (Bose Quiet Comfort 35): amzn.to/2MWbl3e
    🌞 Lamp (BenQ E-reading Lamp): amzn.to/3e0UCr8
    🌞 Secondary Lamp (BenQ Screenbar Plus): amzn.to/30Dtafi
    💻 Monitor (BenQ EX2780Q): amzn.to/2HsmUPZ
    💻 Monitor (LG Ultrawide 34WN750): amzn.to/3dSD7tS
    🎙 Mic Boom Arm (Rode PSA 1): amzn.to/30EZw9m
    🎚 Audio Interface (Focusrite Scarlet 4i4): amzn.to/2TjXsih
    💸 Donations 💸
    💵 One-Time Donations: www.paypal.com/donate?hosted_...
    💰 Patreon: / techwithtim
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    ⭐️ Tags ⭐️
    - C++ Tutorial
    - C++
    - Coding Tutorial
    - Tech With Tim
    - Vectors
    ⭐️ Hashtags ⭐️
    #TechWithTim #C++Programming

Komentáře • 97

  • @lukaslescinskas4844
    @lukaslescinskas4844 Před 3 lety +63

    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.

  • @gilberthangshing7427
    @gilberthangshing7427 Před 3 lety +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.

  • @shamaeelahmed3561
    @shamaeelahmed3561 Před 2 lety +24

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

  • @minemoi7307
    @minemoi7307 Před 2 lety +5

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

  • @abrarmasumabir3809
    @abrarmasumabir3809 Před 3 lety +3

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

  • @stopbysometimes7590
    @stopbysometimes7590 Před 3 lety +15

    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 Před 3 lety +1

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

    • @zombiekiller7101
      @zombiekiller7101 Před 3 lety

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

    • @victor20214
      @victor20214 Před 3 lety +2

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

  • @igoorsimoess
    @igoorsimoess Před 2 lety

    Perfect as always
    Thanks, Tim.

  • @_alfie_phillips_2058
    @_alfie_phillips_2058 Před 3 lety +38

    I love vectors

  • @MrMShady
    @MrMShady Před rokem +4

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

  • @zkierkniekjion4381
    @zkierkniekjion4381 Před 12 dny

    This is a really good quick catch up!

  • @chadjaasofiane4943
    @chadjaasofiane4943 Před 2 lety +1

    really helpful, thank you.

  • @luzgord
    @luzgord Před 2 lety

    Thank you, very helpful!

  • @torishi82
    @torishi82 Před 3 měsíci

    Good summary, short and sweet. Thanks.

  • @almirf3729
    @almirf3729 Před rokem

    Awesome explanation, thanks

  • @ritchielrez1680
    @ritchielrez1680 Před 3 lety +4

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

  • @малосольные-окурки

    simple and useful. great. thank you!

  • @powerfulLVE
    @powerfulLVE Před 3 lety

    Thanks Tim!

  • @giladsivan3735
    @giladsivan3735 Před rokem

    Great Vid, Thanks!

  • @theblock9221
    @theblock9221 Před 11 měsíci

    Very useful thank you very much you explained it really well

  • @souljarohill8795
    @souljarohill8795 Před rokem +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

  • @muhammadismailcareertips3158

    great video tips

  • @ketansonar8299
    @ketansonar8299 Před 3 lety +1

    You could use short hand for loop to iterate over collections

  • @LorenzotheEngineer
    @LorenzotheEngineer Před rokem

    thank you!

  • @harshdevmurari007
    @harshdevmurari007 Před rokem

    great one...

  • @dususbakahyahskahwbwm9113
    @dususbakahyahskahwbwm9113 Před měsícem

    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?

  • @divijagarwal8594
    @divijagarwal8594 Před 3 lety +21

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

    • @divijagarwal8594
      @divijagarwal8594 Před 3 lety

      @Peterolen oh ok, Thanks for telling :)

    • @justin-ju4eo
      @justin-ju4eo Před 2 lety

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

    • @shreyas_._
      @shreyas_._ Před 2 lety

      @@justin-ju4eo you should watch the full video

    • @Musava
      @Musava Před 2 lety +9

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

    • @hitthatrwnoflare9645
      @hitthatrwnoflare9645 Před rokem +1

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

  • @ericcartman1168
    @ericcartman1168 Před 2 lety

    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?

    • @El-Reyo
      @El-Reyo Před rokem

      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.

  • @trithanh9967
    @trithanh9967 Před 9 měsíci

    thank a lot

  • @emodat08
    @emodat08 Před 3 lety +9

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

  • @zaidzaido4428
    @zaidzaido4428 Před 3 lety

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

  • @kwombat5306
    @kwombat5306 Před 2 lety

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

  • @jibinvarghese3066
    @jibinvarghese3066 Před 9 měsíci +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

  • @marekkamyk5518
    @marekkamyk5518 Před rokem +1

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

  • @dienau6313
    @dienau6313 Před rokem +1

    if I type vector v1, what does it mean?

    • @abdul0mar
      @abdul0mar Před rokem

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

  • @hitthatrwnoflare9645
    @hitthatrwnoflare9645 Před rokem +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 Před 14 dny

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

  • @hananissa584
    @hananissa584 Před 2 lety +1

    how can we sort vector and print it??

  • @yaknuelgh
    @yaknuelgh Před rokem

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

  • @mikmik3965
    @mikmik3965 Před 6 měsíci

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

  • @bullymaguire2335
    @bullymaguire2335 Před rokem +1

    what text editor is tim using in this vid

  • @amanuelfessehaye492
    @amanuelfessehaye492 Před rokem

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

  • @techwithdipufrom0ton621
    @techwithdipufrom0ton621 Před 9 měsíci

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

  • @jacobyaacubov8752
    @jacobyaacubov8752 Před rokem

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

    • @eduato_yt
      @eduato_yt Před rokem +1

      I think its sublime text

  • @memeph
    @memeph Před 2 lety

    What code editor you're using?

  • @joshuadodo3488
    @joshuadodo3488 Před 3 měsíci

    What ide are you using please?

  • @mba2ceo
    @mba2ceo Před rokem

    How is the MEMORY physically modified ? What is being done under the hood ?

  • @xx_xxx_xxx_xx
    @xx_xxx_xxx_xx Před 2 lety +1

    10:11
    maybe v1.insert(*(v1),5);
    since the pointer of the *array* starts at the first element address

  • @jensbennedsen8575
    @jensbennedsen8575 Před rokem

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

  • @sparshsinghal9238
    @sparshsinghal9238 Před 3 lety

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

  • @catcoon3746
    @catcoon3746 Před rokem

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

  • @thecodingyoungster
    @thecodingyoungster Před 3 lety

    When is part 2 comming out for typibg race clone?

  • @tiencongnguyen3668
    @tiencongnguyen3668 Před 2 lety

    what is your IDE?

  • @MakerSL
    @MakerSL Před 2 lety

    Thank you so much,

  • @karam3045
    @karam3045 Před 3 lety +1

    Hey tim, will you ever learn quantum computing languages?

    • @zigzag6111
      @zigzag6111 Před 3 lety

      Oh wow did ur clg teach that to u?

  • @ruscyber9765
    @ruscyber9765 Před 2 lety

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

  • @farhanjatt6028
    @farhanjatt6028 Před 3 lety

    Can you start a tutorial on ethical hacking

  • @pythoncure6755
    @pythoncure6755 Před 3 lety

    C++ should be having a standard linear algebra module

  • @Tylers_Gaming_Lounge
    @Tylers_Gaming_Lounge Před 5 dny

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

  • @tanhnguyen2025
    @tanhnguyen2025 Před rokem

    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 !

  • @zakariyeisxaaq5839
    @zakariyeisxaaq5839 Před 3 lety

    How this guy knows so many programming languages 🤔

  • @hectorflorespauner3404

    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...

  • @techbhanucomputer4389
    @techbhanucomputer4389 Před 3 lety

    3rd commenter and 40th viewer

  • @DreaminBig
    @DreaminBig Před 3 lety +1

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

    • @Dcookies100
      @Dcookies100 Před rokem +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

  • @kamil8263
    @kamil8263 Před 2 lety

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

  • @LorenzotheEngineer
    @LorenzotheEngineer Před rokem

    :)

  • @johnchu869
    @johnchu869 Před rokem

    mark

  • @joeboehaha
    @joeboehaha Před 4 měsíci

    This dude have very less subscriber feeling bad 😢

  • @clashersamir1625
    @clashersamir1625 Před 6 měsíci

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

  • @Victurf
    @Victurf Před 2 lety

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

  • @lokeshwaran9884
    @lokeshwaran9884 Před 3 lety +1

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

  • @UserpingSky
    @UserpingSky Před 2 lety

    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 Před 2 lety

      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!

  • @jhonlopez27
    @jhonlopez27 Před 2 lety

    I didn't understand nothing about this lesson

  • @benjaminhutz2405
    @benjaminhutz2405 Před 2 lety

    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