Multidimensional Arrays in C++ (2D arrays)

preview_player
Показать описание


Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer

Gear I use:
-----------------

Рекомендации по теме
Комментарии
Автор

Hope you guys enjoyed the video! Just a quick note: the code that I wrote at 16:47 should really be *a2d[y][x] = 2;* since we want the inner loop to iterate through the actual int array data.

Don't forget to drop a comment below if something still confuses you about multidimensional arrays, and have a nice day! <3

TheCherno
Автор

I have been programming for 24 years, and used C++ for 15 of them, I make all my money from making my own programs... But I have actually learnt a few really useful things by going back and checking everything against your videos. Turns out there is always more to learn, and I like your teaching style. Thanks.

TheSmellyMoo
Автор

Been coding in C++ for 4+ years now, don't really know why I'm watching these videos, but sometimes something new pops up. So even though I knew all of this, it was really nice to see you think about not only the intuitive way of doing something, but also the (most of the time) better way. Most people teaching C++ (or any language really) just looks at one approach, and it's usually the intuitive one not the better one.

Really great video! Keep it up!

totalspelnerd
Автор

You should have mentioned the much simpler stack declaration of such arrays: int a[n][n];. Also, if you want it heap allocated and don't want fragmentation, you could do int* a=new int[n*n]; int** m=new int*[n]; for(i=0;i<n;i++)m[i]=a+n*i;. This way you have all elements in a row in memory, but you can use the nicer syntax m[i][j]

danibarack
Автор

I just did a search for this topic on your page the other day. I'm so glad to see it up !! I absolutely love your work and it's helped me understand c++ in a way I never thought possible. I'm self teaching so your work means a lot to me !! Thanks

mzjayne
Автор

Love this video. Would love to see an in-depth video of writing a freelist/mempool that also takes into consideration dynamic allocation when the pool is empty and the optimisations around it.

Xxpr
Автор

it's 2022 and I'm learning a ton from your various series - i love that you show how simple and easy things can be, as well as demystifying complex stuff - amazing energy - huge thanks and i'll defo be donating to your patreon.

doctortrouserpants
Автор

I would love to see a video on caching and accessing memory in the right way

frisosmit
Автор

First time I understood arrays in C++. So, I have to say, good teaching! Thank you for that!

christianlennertz
Автор

At 0:45 the "C" in the guys surname ALMOST lines up with the "C" logo in his laptop. Makes me think of r/mildlyinfuriating...

kanskejonasidag
Автор

The timing on this is incredible. I am about to start an assignment on this topic and it couldn't have come at a better time :D

MrDarkyosh
Автор

This is super cool, man. Realizing that this whole "matrix" or 2D, 3D, ND arrays can be flattened and it WILL BE FASTER is super cool. Love the way you are looking on a code-things, from a different angle i would say. Thanks.

dmytroboiko
Автор

Love you advanced insights and the optimization considerdations! Down with 2D arrays!

VOLTDOGmusic
Автор

As always, great video!

Although I'm already familiar with most concepts you teach, I learned it all in other languages (mostly Java and C#), so they're a great way for me to get more familiar with C++

Regarding this particular video, I do feel like using a visual representation could work better for explaining multidimensional arrays - at least that has been my experience when teaching other people.

Best of luck and keep up the excellent work!

victorlucki
Автор

The vibration at 5:25 had me looking all over for a rogue phone going off in my room.

Calebinator
Автор

If anyone is curious about the time difference between allocating/deleting a 3d array versus a 3d flattened array of size 5x5x5. It's significant. Below are my bench mark times using the timing method learned from previous video:
3D ARRAY
0.0278ms
0.0164ms
0.011ms
0.0112ms
Average: 0.0166ms

3D ARRAY FLATTENED
0.0015ms
0.0008ms
0.0025ms
0.0009ms
Average: 0.001425

Optimization improvement by 11.65 times faster. WOW

mpphelps
Автор

Thank you very much for this video tutorial! I was having such a hard time understanding pointer to pointer multidimensional array, and you explained it so well. Thank you again.

seankang
Автор

After watching other learn c++ videos, this is really learning c++ down the c++ rabbit hole. I’ve nearly grasped this but after reviewing and coding test examples it will make total sense. Great video series.

Disillusioned_one
Автор

12:43 was super helpful. I was having trouble with memory leaks, so thank you so much!

jadenataylor
Автор

I have also been watching your series on the Sparky game engine and this explanation on 2d arrays and pseudo 2d arrays made the [ x + y * w ] notation make so much more sense.

spamfilter