Arrays in C++

Поделиться
HTML-код
  • Опубликовано: 2 июл 2024
  • Patreon ► / thecherno
    Twitter ► / thecherno
    Instagram ► / thecherno
    Slack ► slack.thecherno.com
    Pointers ► • POINTERS in C++
    Debugging ► • How to DEBUG C++ in VI...
    Series Playlist ► • C++
    Gear I use:
    -----------------
    BEST laptop for programming! ► geni.us/pakTES
    My FAVOURITE keyboard for programming! ► geni.us/zNhB
    FAVOURITE monitors for programming! ► geni.us/Ig6KBq
    MAIN Camera ► geni.us/t6xyDRO
    MAIN Lens ► geni.us/xGoDWT
    Second Camera ► geni.us/CYUQ
    Microphone ► geni.us/wqO6g7K

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

  • @TheSim00n
    @TheSim00n 6 лет назад +247

    15:15 sizeof(int) is 4 bytes so you'd end up with 1? Were you reading your own comment while saying this or am I missing something?

    • @TheCherno
      @TheCherno  6 лет назад +277

      Lol yeah imma blame that on the jet lag... it would be 4 / 4 which is 1. Still not the size of the array though so the point still stands. :)

    • @alibaspinarele
      @alibaspinarele 5 лет назад +27

      @@TheCherno dont need to be smart to understand that, do not worry keep going :)

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

      Hey, I just watched this video after std::array and you contradicted yourself. Maybe because you didn't know it when you created this video but in this one you say there's an overhead due to size() but in std:: array video you pointed out that it's a template and does not add any overhead as it simply returns the value. Just wanted to make sure people watching this know that you actually recommended using std::array over c-style array due to many advantages.

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

      @@andruha1067 The overhead is the whole bounds checking and whatnot.

    • @TheMR-777
      @TheMR-777 3 года назад +1

      @@andruha1067 I agree, but as @FFS said, yes, there are many bound checking, and other "CHECKS" which a bit slow down the performance of our code

  • @NoName-tn8rq
    @NoName-tn8rq 5 лет назад +322

    cherno: "We're gonna wrap this up pretty soon"
    me (moving mouse):"no, you're not"
    XD

    • @omri1324
      @omri1324 4 года назад +14

      lol this literally just happened to me aswell

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

      same lol

  • @julien-scholz
    @julien-scholz 6 лет назад +320

    "I like to live dangerously" Lmao

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

      @@thecashewtrader3328 I'm pretty sure Austin Powers said this before GTA SA

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

      _"Hey, Pikaju!"_

  • @theturtlepwn
    @theturtlepwn 5 лет назад +200

    Part of what makes you a great programmer/teacher is that you have a deep technical understanding of how all of this works, and you're not afraid to share that information even though it may seem intimidating.

    • @Calm_Energy
      @Calm_Energy 5 лет назад +25

      Agreed: Sometimes it's tough to know what the audience already knows, I guess it's always good to error on the side of over explaining.

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

      That's how u know he's about that LIFE.

  • @roshiron1816
    @roshiron1816 3 года назад +56

    RUclips C++ videos are like looking up a word in a dictionary and the definition is full of words you don't understand so you look up those words and the chain continues. AAAAARRRGGHH!!!!!!! *slams head on desk*

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

      Bruuuuh. I know this was 2 years ago but I'm going through the same thing. I'm always checking the comments to see if people understand and surprisingly, they seem to. But maaaan!!!

    • @Byynx
      @Byynx 7 месяцев назад

      ​@@mwenge6355That's normal for everyone that is starting, don't worry.

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

      @@mwenge6355 I understand almost all of his videos, the reason is that I've been programming for almost 10 years now, so my advise is to practice video by video and look up some written docs of the same concept that you didn't understand from the video. good luck

  • @nitinnair1682
    @nitinnair1682 5 лет назад +69

    17:56 "however....i like to live dangerously"...XD

  • @femloh
    @femloh 5 лет назад +15

    You have made me finally UNDERSTAND pointers PROPERLY. I see their potential now. Its just you accessing memory locations and playing around with either those locations or the values in those locations. That is all pointers are !! They are not doing anything weird. Smh. Thanks man. You have no idea how clear this has made things for me. Makes we actually want to learn Machine/Assembly Language

  • @g00dvibes47
    @g00dvibes47 5 лет назад +27

    Dude, phenomenal video.
    Love the technicality (pointer arithmetic (assembly OFFSET), heap alloc/dealloc, little endian, constexpr, c++11 arrays, etc)... great stuff

  • @Luingus
    @Luingus 2 года назад +13

    So to summarize:
    Arrays store values of one type together
    The Array Name by itself is a memory address
    Arrays can be indexed through both for loops and pointer arithmetic
    Arrays can be made dynamically or statically (on the stack or the heap)

  • @adrianoldchannel2494
    @adrianoldchannel2494 6 лет назад +4

    You're more than a teacher you're a perfect explainer. I wish if there's more like you or as good as you. I've been watching your series from last night and I'm just stuck on your channel. That's awesome.

  • @NaveenKumar-vj9sc
    @NaveenKumar-vj9sc Год назад +2

    you are the best so far in my experience of learning online. In my perspective, you don't share knowledge, but rather EXPERIENCE.
    I am gonna now watch all the c++ experiences taught by you.
    Thank you soooo much.

  • @informativecontent4778
    @informativecontent4778 6 лет назад +12

    9:02 this is some wild shit

  • @pacan7380
    @pacan7380 4 года назад +8

    The Cherno videos have become my morning routine :D

  • @colinterry7261
    @colinterry7261 6 лет назад +1

    I like these longer videos where you really go in depth!

  • @axelandersson657
    @axelandersson657 6 лет назад +64

    5:16 Actually, less than or equal to is not performed separately, as (less than OR equal to) is the opposite of greater than, and vice versa. However, the code is more readable and more understandable if you write for (int i = 0; i < SIZE; i++) instead of for (int i = 0; i

    • @treyquattro
      @treyquattro 5 лет назад +21

      Correct. In this case the compiler will emit a JL (jump if less) or JLE (jump if less or equal) operation (on an x86 processor) for < or

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

      @Ebola Virus It may depend on how the emitted code is structured. In a very typical for loop you're counting up to some limiting factor so at the bottom of the loop you do the test and jump back to the top if the counting variable is less than the compared value. However, this is very dependent on a) the code that the programmer wrote (obviously) and b) how the compiler, optimizer and code emitter organize the object code. In the x86 world JNL is an alias for JGE (jump if greater or equal). These conditional jump instructions test flags in the flags register to determine whether to jump or not. They can test multiple flags simultaneously, such as the O(verflow) and S(ign) flags in the case of JL/JNL
      If you wrote *for (int i = 0; i < 5; i++)* then I'd expect the compiler to emit something like:
      for_loop:
      .
      .
      mov rax, [esp-8] ; i
      add rax,1
      mov [esp-8],rax ; changes no flags
      cmp rax, 5 ; sets CF,OF,SF,ZF,PF,AF flags
      jl for_loop ; jump if SF != OF
      nop
      In the case of *i < 5* the Sign Flag will be set but the Overflow Flag won't be and the jump will be taken. In the case of *i == 5* (the terminating condition) both the Sign Flag and Overflow Flag will be reset and the jump won't be taken and the CPU will continue at the NOP in this case.
      There's nothing stopping you writing code like this:
      loop_top:
      mov rax,[esp-8] ; i
      inc rax ; adds 1
      mov [esp-8],rax
      cmp rax,5
      jl loop_body
      jmp somewhere_else
      loop_body:
      ; do something
      jmp loop_top
      This is slightly less efficient, but the compiler (or hand-written assembler) might produce that kind of structure depending on size of code blocks, processor mode, etc. (in the "old days"(8/16-bit code), a conditional jump could only move the instruction pointer by -126/+129 so you'd have to reverse the sense of the conditional jump and use an immediate 16-bit jump e.g. if the loop code was longer than the distance allowed in the relative conditional jump.
      The only issue in the video was that Yan incorrectly said that writing e.g. *i

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

      but the computer does not understand that. it is why there exists a greater than or equal to operator

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

      @@treyquattro Modern compilers won't emit a JL or JLE instruction, it will convert it into a JE instruction and compare it to 5 in this case to terminate the loop. Which makes sense considering it's just an XOR that has to be 0 as a result. Whereas if you use a JL or god forbid a JLE instruction it's a bitflip + 2s complement of the second value followed by an addition and subsequent interpretation of the result as a negative or positive number. If you compare sizes and whatnot it actually needs a lot more cycles to do so a modern compiler will omit that instruction. Check Godbolt if you doubt me.

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

      @@Finkelfunk it's up to the compiler and optimizer how it organizes code - what tests and jumps it makes. There may well be optimizations to be made in the arrangements of what conditions to check, but etiher way a jump is going to be made either when the final condition is reached, or when an intermediate condition happens, depending on how the compiler has decided to lay out the code. The issue is that whether the compiler decides to emit JE, JL, JLE or something else (you may see aliases such as JC or JNAE for JB e.g.), the instruction timing is going to be identical - it's a test of a flag and a jump or not on result. Different flags get tested by different instructions but all Jcc (jump on condition code) operations (x86_64) have the same timing for the same sized operands. Saying check it on Godbolt is not very helpful because there are tens of different compilers on Godbolt, each with a variety of optimization settings. What gets generated differs from compiler to compiler, and version to version, and depending on the optimization levels chosen.
      The original issue was that it was mistakenly asserted that a

  • @alexshepler403
    @alexshepler403 6 лет назад +1

    Love these videos. This is helping me out in my cs131 class at evcc

  • @red6fauser
    @red6fauser 6 лет назад +2

    u did really good job with c++ tutorial series.

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

    Very thoughtful introduction - many thanks.

  • @MegaFirst123
    @MegaFirst123 6 лет назад +9

    Yes Cherno, we want more long videos please!!

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

    Please consider making C# videos..! The way you teach, express things is just amazing. I feel like I don't understand other people's teachings.

  • @1Naif
    @1Naif 6 лет назад +14

    I've Learned new things today... Thanks.

  • @mohammedobad2174
    @mohammedobad2174 6 лет назад +1

    great stuff cherno

  • @aPoCoTuToDac
    @aPoCoTuToDac 6 лет назад +49

    11:26 a pretty damn good example of *pointer* :D

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

      🤣🤣🤣

    • @17reason
      @17reason 3 года назад

      😂😂🤫

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

    You went quite deep in this one. Thanks.

  • @mohnish.deshpande
    @mohnish.deshpande 3 года назад +1

    Mate you are just great!!!
    Especially because you teach everything clearly and quickly 😎

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

    another EXCELLENT video

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

    just incredible. thank you

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

    Another great video, way easier to understand then my university teaches.
    Thanks

  • @procactus9109
    @procactus9109 6 лет назад +10

    Playing with addressable LED's with an arduino, Ive seen some weird things going on when I accidentally misuse an array. I had no idea what was going on, LED's doing strange things. I did work out that arrays still try to work, I assumed it just used the memory as if it was bigger. Got some cool effects from it.
    I look forward to the spin offs as you say :)

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

    Cherno sos lo mas grande que hay.

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

    6:14 just a small correction for the great video, usually the C/C++ runtime knows the size of the arrays (malloc/realloc... other functions) and of course the operating system as well see VirtualAlloc, HeapAlloc, ... on Windows and even on windows the way it's kept differs between the type of allocators which are used (small/medium/large pool allocation)

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

    Great explanation

  • @jackle3002
    @jackle3002 3 года назад +8

    Hey The Cherno, every so often i see you doing some fancy keyboard combo magic which resembles VIM operations like selecting chunks of code quickly, moving line up or down, duplicating etc. I'd be pretty interested in learning how you've set that up and knowing more about your input "workflow". If you've already done a video on this please link me :)

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

    Thank you very much!

  • @codastudiode
    @codastudiode 4 года назад +2

    Cherno, thanks for your awesome videos! could you please make a tutorial series about game programming patterns.

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

    I watched neatly a third of this series. Insane stuff. I'm gonna start trying to mod Open Roller Coaster Tycoon 2 to actually put my skills to use.

  • @mahekshah9337
    @mahekshah9337 5 лет назад

    concept is tricky in example code but you made it simple . THANKYOU

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

    Great video!

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

    thank you very much for this information you teached me

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

    These are some of the most useful programming videos on the internet because of your teaching style and structure.
    First thing that makes you a cut above the rest, is because you cut straight through the bullshit. ie: A variable type is actually nothing special. ie: an array is actually just a small stack of variables, and is sort of actually nothing special.
    Second thing: The memory viewer. Mind blown! For as long as I've been trying to learn these concepts (and bowing before variable types with a cult like religious reverence), I haven't found any instructor that actually does this. Instead every tutorial or course (I've taken) leaves this sort of thick fog between memory and what we're trying to achieve. As if memory is this magical thing we must never look upon or speak the name of, except in anything but convoluted riddles. Even in my Computer Science 104 course in college they taught us the hardware concepts of memory on the whiteboard, but never even attempted to connect it's fundamental truths to the code side of things. Makes me feel like Memory viewing should really be a part of the introduction, instead of being left only until advanced concepts.

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

    Hey man, you are amazing. YOU ARE THE C++ REFERENCE

  • @matusjakuboc9623
    @matusjakuboc9623 5 лет назад +1

    Thanks! By watching this series i improved my programming skills in c++ A LOT. I hope you will keep doing such a videos

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

    In a video of more than 15 min, I usually overwhelmingly check the remaining time. But with Cherno, time flies.

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

    you are really great teacher cherno thank you a lot!

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

    I started playing with arrays, just to remember how it works and found out that you can change a private atribute of a class (even out side of its scope) using pointers, nice >

  • @abx4t
    @abx4t 4 месяца назад

    Thanks for this!
    By the way, you REALLY talk with your hands!!

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

    for using the value of std::array::size() in for loops, you've got to change the data type to signed integer or either declare the variable for the initial value as an unsigned integer

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

      the "perfect" solution would probably be to use size_t for the type of the iterating variable, because by definition size_t "can store the maximum size of a theoretically possible object of any type (including array)"
      also, you can just do a ranged for over the array if it is only the elements that you need

  • @mpwsh
    @mpwsh 6 лет назад +10

    I just finished the series in less than 1 week, thank you so much for this great information.

    • @9696Punk
      @9696Punk 6 лет назад +5

      2 days ;D

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

      @@9696Punk yall are too powerful to be kept alive

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

      @@9696Punk 8 hours a day???????

  • @greob
    @greob 6 лет назад +1

    Good tips! :)

  • @qwertygamer8386
    @qwertygamer8386 6 лет назад +1

    It helped me a lot for my exam

  • @richtourist
    @richtourist 6 лет назад +27

    At 16:13 you say "you have to mark it as STATIC". Why doesn't the CONST meen it is known at compile time (if it is constant), why the STATIC as well?
    You are easily the best C++ teacher I have seen, and your videos are perfect in style and content.

    • @vighnesh153
      @vighnesh153 4 года назад +2

      @Peterolen Yea. because there is no 'readonly' in C++ like it is in C#. There const means compile time const and
      'readonly' means that it can be modified in the constructor.

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

      @@vighnesh153 I think the C++ spec recommends to use constexpr instead of const as const is more used as "readonly" now (or I might be mistaken maybe it was someone else lol)

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

      the const keyword is not necessarily known at compile time. It just means it can't be changed once it's initialized. For instance you can have the following:
      int i;
      std::cin >> i;
      const int x = i;
      and it is perfectly valid though the value isn't known at compile time. Therefore the compiler would have no way to know how much memory to set aside if you did int MyArray[x]
      Whereas constexpr or const static both must have constant values that are known at compile time.

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

      @@vika3750 Thanks for that, Vik A. 🙂
      Think I was just getting const and static confused for some reason.

  • @user-cx7te6pl2h
    @user-cx7te6pl2h 3 года назад +1

    God Bless you. Put more adds on this baby, you deserve money

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

    its awesome! man

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

    Me: Struggling to get the element count of a heap allocated array and failing miserably.
    The Cherno: It's not really possible in C++*.
    Me: Suddenly feeling less incapable.

  • @Villentrethenmerth
    @Villentrethenmerth 5 лет назад

    Pure gold.

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

    Bro , all what i can say is thank you
    keep up buddy

  • @cap-advaith
    @cap-advaith Год назад +1

    where the hell was this series ? such a golden playlist

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

    Awesome video❤

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

    You bring up some basic yet meaningful concepts that other introductory programming texts/videos don't. like why < is better than

  • @zerospeed6412
    @zerospeed6412 4 года назад +6

    Me watching this video hoping to clear all confusion just to be greeted by more confusion... Guess I'm on my own now.

  • @RogerTannous
    @RogerTannous 3 года назад +6

    16:14 As the size variable should be known at compile time, you've stated that it should be static const (or constexpr). It can also be declared in a #define statement, and easily remembered, like in
    #define ARRAY_SIZE 5
    int example[ARRAY_SIZE];

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

      Yes, that's exactly what I'm thinking about. Is it okay to write macros in-line with your code? Or is it better to just put all the macros on top of the soruce code?

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

      oh no bro macros are evil (because they literally just replace text in your code) avoid them at all possible costs, use them only if it's absolutely necessary

  • @johnadams7843
    @johnadams7843 5 лет назад

    Since accessing an array is just an arithmetic operation (adding an offset to a base address) you can do something silly like saying 0[example] = 1; to set the 0th index of an array name example to 1, it would be stupid to do this but like you said you can do just about anything with C++, love the videos :)

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

    thank you

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

    perfekt ...thank you so much for the video.. cherno

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

    Thanks

  • @thepanable5004
    @thepanable5004 6 лет назад +1

    Daddy Cherno feeding us more videos

  • @rcookie5128
    @rcookie5128 6 лет назад

    much learned today!!

    • @rcookie5128
      @rcookie5128 6 лет назад

      I'm really excited for the "juicy stuff" ( ͡° ͜ʖ ͡°)

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

    15:10 i think the size of an integer pointer is 8 bytes and not 4 bytes !

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

    dude. Thanks.!

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

    thank you share~

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

    There are also std::size() and std::ssize() to retrieve the size (or count of elements) of a raw array (although they work for standard arrays as well), I don't know if these methods were there by the time this video was made but if I'm not wrong they seem to be the safe way to do it now.

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

    perfect

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

    I certainly do enjoy your videos, long or short~!!!

  • @arbaazawan
    @arbaazawan 6 лет назад +1

    Dude! you are superfast most of the times i have to stop the video and play it in slowmo

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

    15:55 Okay, that is interesting. That actually worked for me (no errors, compiled and executed fine) XD. Weird...

  • @Nicolas-gq9vu
    @Nicolas-gq9vu 6 лет назад

    Nice video

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

    So I googled how to find the size of an array because I needed it for a code I was working (note, I'm very much still a beginner when it comes to coding), and while one of the methods was that method you showed of doing arrSize = sizeof(arr) / sizeof(value), another way which was mentioned was this way that I prefer but don't fully understand which uses pointers. The code for this is arrSize = *(&arr + 1) - arr. I didn't use this inside of a function, but my guess is it would still work inside of a function considering that it uses pointers and addresses of. Like I said, I don't fully understand the code, only that it works for finding the size of the array, so if anyone could explain it in detail, I know how pointers work, and I know about addresses of, I just don't understand this specific way of finding the size of an array.

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

    its because of things like "static const int size = 5;" that I love c# so much that and GC

  • @krec348
    @krec348 6 лет назад +6

    Yes!! We're finally getting to more interesting topics, WOOOOOOOOOO

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

    15:15 the sizeof(pointer) for Visual C/C++ will allways be equal to sizeof(int), because these should be equal to the size of the registers are used in order to not create bottlenecks in CPU operations => the sizeof(pointer)/sizeof(int) will always be 1 for VCRT

  • @Alexandre-db2yw
    @Alexandre-db2yw 3 года назад

    I love you. Really.

  • @reidpattis9478
    @reidpattis9478 5 лет назад +1

    Great video. Still, I think this video would make more sense to be the 7th video on the playlist.

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

    9:35 “I’m going to wrap this up pretty soon”
    But I do like the lengthier video though

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

    3:23 Hey! It's not a pointer.
    An array will be implicitly converted into a pointer to its first element, but it's not a pointer.
    Pointers store address, and arrays store their elements, so they're definitely different types. If you get the address of a pointer (`&ptr`), the result is a pointer to the pointer; in the other hand, if you get the address of an array, the result is a pointer to the array.
    As what you saw, in the memory, there are five integers instead of a "base address".

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

    11:26 nice pointer

  • @koungmeng
    @koungmeng 5 лет назад +2

    how about :
    std::vectorarr(5)
    std::cout

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

      In that case you're initializing the vector class, and the parameter 5 is its size
      so std::array myArray is equal to std::vector myArray(5)

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

      Vectors are made on the heap

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

    8:40: That is a proper "pro" move. Nice

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

      That's a proper "I invoke UB because I don't care about my code". Nobody sane in the industry would ever deliberately invoke undefined behavior, that assignment might as well make your PC order pizza for you.

  • @carljalal3855
    @carljalal3855 6 лет назад

    Would that array created on the heap after the object instantiation get destroyed when the object is destroyed, or do we have to manually destroy it (for example in the destructor function) or else it would be a memory leak?

  • @SrNavi155
    @SrNavi155 5 лет назад +2

    Is there a video from this channel that explains associative arrays/hashmaps/dictionaries ?

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

    "However, I like to live dangerously" xD xD

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

    5:18 you said a "

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

    5:23 I checked the compiler explorer and it is in fact not correct that it will do a less than and equals comparison. Basically, compiler magic and all that optimizes it away, so no matter how you write it, it always uses a "je" instruction. But it is definitely more readable to anybody working with your code.

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

    If for example I have dynamic array of class instances that all need to call destructor, because class contains a pointer, when I call delete[]array will it call destructor for each one instance or do I need to do it separately before calling delete[]?

  • @HappyMatt12345
    @HappyMatt12345 Год назад +4

    Couldn't you also specify a set of values when you create the array rather than use a for loop to define their values?
    For example int myArray[5] = {1, 2, 3, 4, 5};
    It would be more efficient to use a for loop if you have a large array, but if there are only a few elements it's quicker to write it this way in one line than to write an entire for loop imo.

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

    the sad thing is i cant tell if youre joking when you say "i dont wanna make this too complicated" XD
    thank you for these free tutorials

  • @WayneRiesterer
    @WayneRiesterer 5 лет назад +1

    Are raw arrays typically used in gaming where performance is key?

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

    Arrays are kind of like classes but not really. You give an array multiple variables and then you can refer to every variable at once.

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

    9:12 is really wild.

  • @nilsmelchert776
    @nilsmelchert776 6 лет назад +1

    Well explained my friend. I will subscribe to be a Patron ;)

  • @Lillu700
    @Lillu700 5 лет назад +1

    You could use pointer arithmetic to loop through your 50 individual integers.