Raw Arrays and std::array in C++ | Modern Cpp Series Ep. 13

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

►Lesson Description: In this lesson I teach you our first data structure in this series, the array! Arrays are very simple but frequently used data structures. They allow us to store a collection of data in a contiguous block of memory. In modern C++ we also have the std::array container, which provides additional power and error-checking mechanisms for our array.

As a teaser, I also show you how to initialize an array using a loop, as well as with std::iota which lives in the numeric library..

►Please like and subscribe to help the channel!
Рекомендации по теме
Комментарии
Автор

I really appreciate the approach you've taken here with introducing STL concepts early on, especially in such a natural way. This often feels like a rushed after thought in other tutorials I've watched.

scotto-robotto
Автор

Hi Mike! Thanks for this great C++ series!
The only one minor issue I've noticed in this video: I've learned from Jason Turner's videos, that calling std::endl in a loop is considered as a bad practice. He advised to use '\n' instead, and if one really wants to flush the buffer so it would be better to use std::flush outside the loop.

dino_source
Автор

Insightful and conceptual video, great learning ! Thank you.

shreya_sigh
Автор

Enjoying the series thus far, and just subscribed to your channel

chesspool
Автор

Hello Mike, for the record, I'm brazilian and I'm really enjoying your lessons!
As for this one, a point raised me a doubt bc when you assigned a value outside the range previously set up to 'Ids' array, you received a 'segmentation fault' message, but in my case I didn't receive anything and it compiled well and even was able to execute. Do you know the reason of this behavior?

matteusgutemberg
Автор

Hey Mike. Great video!
Can you please tell us how is the I integer being able to access the elements in the array.
Thank you

kaydend
Автор

Hey Mike .. really good stuff! Interestingly and by accident, I ran the iota snippet without declaring the library <iterator> for std::begin and std::end. And it compiled and ran successfully (gcc C++17). Could you verify?

GaryChike
Автор

Is there a quick way to initialize raw arrays with a default value? Or we always have to use algorithms?

farianderson
Автор

Hey Mike, really good video!
Question: can I use variables when defining a std::array?
I'm trying to do this, but i'm getting an error:

int user_array;
std::cout << "How many elements?" << std::endl;
std::cin >> user_array;
std::array<int, user_array> arr;

Thank you so much! <3

guitart
Автор

How can std::end(ids) infer the size of the raw array when size isn't a property?

swagatochatterjee
Автор

thanks for the lesson. however, why we access the first element of an array using 0 and not 1?

deepblackoutlaw
join shbcf.ru