Thanks for watching! Don't forget that the first 1000 people who click the link will get 2 free months of Skillshare Premium: skl.sh/thechernoproject10
Somebody asks that on almost every one of those videos and I’m pretty sure the reason he hasn’t done a video on the subject is because Makefiles, etc., aren’t part of the C++ language, and this is a C++ language tutorial. Plus, he uses visual studio, which doesn’t use Makefiles, so it would be pointless.
Those are poor excuses for not doing it. Plenty of projects that use C++ make use of cmake or make files. He probably runs into them quite a bit, especially with open source projects.
Suggestion: linked lists then binary trees. My knowledge of this area is a little patchy and hearing a second expert explanation of a topic is always welcome.
I agree with this order, binary trees are in of themselves a linked list. Hopefully he'll explain doubly, single, and circular linked lists sometime soon.
@@jamesmnguyen Yeah, but that only works for two data structures, vector and array, and the latter works because arrays decay into pointers. Implementing iterators for anything else is more complicated.
@@oracleoftroy Iterators for linked lists are also pretty easy. It gets harder for trees though, because you need to figure out the logic to access every element in the right order. Especially if it is a search tree, where the order is important
Awesome man! Very glad you opted to start delving into data structures and algorithms in your C++ vids! Very much looking forward to more of these! Thanks so much.
I'm glad you're doing this series lmao. I took a data structures course at my university last year, and now I can keep myself refreshed on the material through these videos so I don't forget all these concepts
That "noise" at the top is very useful. It allows you to write things like using container = std::array; container x; memset(x.data(), 0, x.size() * sizeof(container::value_type)); Then when you need to change int to uint64_t or uint8_t, you only need to change it in one place. Putting sizeof(int) in that memset is buffer overflow waiting to happen.
This series is super helpfull! :) Edit: Also, the way Cherno explains the things (dissected and explained step by step, from basic functionality too the more complex results) is so much better then most written documentation you can find..
Thank you so much ! Looking forward for the iteraror implementation. Also, I'd like to see you talk about boost library, more specifically boost::bind methods (also also, I believe they have been integrated into STD by now)
glad you're making data structs & algos series. would also be good to mention using arrays unless you need optimization is bad practice, and more generally optimizing before you need to. and it would be nice if you go into some of the nitty gritty details about why there's an overhead from not keeping your data contiguous; it's not self evident, and especially mysterious if you know your programs use virtual memory.
I was waiting soo eagerly for this 🙏🏼 your videos have become my bread butter daily these days haha. Thanks so much for sharing all your knowledge cherno!
I am an undergraduate student. I already love your content and find it really inspiring. But can you please do more content related to basics and Data Structures?
Could you do a video on ideas for projects beginners/intermediate C++ programmers could do to add on to their resume? Currently going into my 3rd year in college, and I'm looking to apply for internships for next summer, but I don't really have any projects to put on my resume nor do I know where to start.
Thank you So Much , you are the best channel i've seen ... you are beyond professional. You are my inspiration in learning c++ and, i hope you keep making videos, love you Cherno.
Honestly, I did not touch c++ since 3rd year at uni. This video made ne remember a lot about c++ and tought me more about it than 2 hours at uni ever did) Def subscribed coaus of that. Even though I don't use c++ at work)
I'm really gonna LOVE this! I was always trying to implement different STL classes that I use and love myself. And also to expand and add upon them. My favourite ones were String and List(dynamic array). Thanks a lot for your great content Yan 💙💙
A few remarks The STL array has its underlying array field public to allow for aggregate initialization, like you can do with a plain array. All the type members like pointer, const_iterator, etc. are actually required by the standard, not just in MSVC implementation
you know , I had sworn that I will never understand loops but after watching your video on the topic , I am on the safe side now, I guess, Thanks man....
I'd love to see a simple compiler series using flex and bison to generate a abstract syntax tree that is class based. Then see it in action. An AST that can be reused in other languages you work on.
I'm getting "true" from empty() on std::array with MSVC. So there's probably a different version of that function somewhere in the code, or something like that.
While arrays may be easy to deal with, I would certainly like to see you implement some much more complex types like tuple. XD Also, those size_type things are required by the standard, so that template meta-programming on std containers is easier. std::array are implemented as a struct containing a public member of the array, which makes the struct an aggregate, that enables the aggregate initialization syntax (like std::array array{ 0,1,2,3,4 };) without requiring any constructor to be implemented manually.
Careful with alloca(), it is non-standard (even in C) I think it's only standardized by POSIX, which makes sense because Microsoft's version easily breaks in try/catch blocks. alloca() does have its uses, but if you can get away with a stack array or a SmallVector, you probably want to use that instead.
People, never ever in a million years do a memset call like was shown in this video. That is allowing external code to operate in the private parts of the class. Place the memory setting code INSIDE the class. That code there I would have marked as needs work if I ever saw it in a pull request.
The problem I had with these types of structures is that it becomes annoying to pass the arrays around in functions. since Array is a completely different type than Array unless there's some magical c++ way to do it...
Typename is for specifying a custom type, he doesn't need a type parameter as it will always be an int array (if it was customizable that would be done), he wants to specify a custom SIZE as an int/preferably size_t so that is parameterized in the template args
Would love to see videos implementing data structures of other STL containers like vectors and strings with things such as iterators within them in the future. Anyway, great video :)
The alloca has a larger issue there. Unrelated to performance. The problem is that it will be freed after the constructor retutn/exit the scope of the function. Meaning you can not use it like that. Only way to get around that is to make the allocation in the scope where the object is created. If you do it like you did it might compile and work in some cases. But in reality you are using stack memory that the program sees as free and might be occupied by other stuff. So it's an undefined behavior. Alloca is awesome, but dangerous if used wrong like that. Should make eha clear.
Great Video! I just made a dynamic array and a doubly linked list last semester. It is so much harder than it oringinally sounded. Would love to see how to create a (un)ordered (multi)map or a priority tree of some sort! Thanks again! :)
Suggestion: I know this isn't a data structure, but somewhat related. Could you talk about endianness and how to deal with it? I suppose this is more to do with data punning than anything, but as a firmware engineer working in c, it would be nice to know how one deals with it in c++.
We can technically define: const int size = 7; And before using it to define an array, we can change its value via a pointer like this: int c = 5; const int a(c); cin >> (*(&c + 1)); int array[a] ////////// Now I know that array size must be declared at compile time but this just works... I wonder what strange behaviours will be caused by this hmmmmm...
The TAs at my Data Structures class allocate *everything* in the heap, even objects which already allocate to the heap by themselves. And they don't even care about releasing the used memory before ending the program. The program may compile and run one way or the other, but I think that's a very bad habit (and bad habits die hard). At least they could tell us we shouldn't do that in production environments or something like that.
In a case where a class constructor takes a pointer of data in parameter and stores it in a class member, I can't quite find a good way to deal with the nature of the pointer. Is there a way to tell if it was stack allocated or heap allocated? The main use case is for a class interface for users who don't exactly know how the class is implemented. If the data is stack allocated and passed to an instanced of the class which is heap allocated, the class should copy the data and delete it in its destructor. But if the data is already heap allocated copying it is a waste of performance and memory. Is there a prefered way for this kind of situation? I am missing an abvious poin?
You should copy the object regardless of whether it is stack- or heap-allocated. Even if the data is allocated on the heap, your class is now dependend on data that it does not own. Someone else will eventually have to delete that data and you might be left with an invalid pointer. However, this could also be solved with an std::shared_ptr. The shared pointer would guarantee that the data can not be deleted while your class is still using it. The shared pointer only allows for heap-allocated objects though, so you option 1 might be your only option.
Very good content as always. In one of the first videos (video 2 of C++ Series) I downloaded your vs settings. They seems to have changed. Do you update the link or give a one with your updated settings?
I dig arrays but it feels like whenever I'm writing a program (mind you I'm not a programmer by education or profession, I just have had some classes in my degree), it's a case where you ask the user the size of the container (or the data set to be more accurate) if you're not reading it from a file. And c++ doesn't let me get that size, then create an array with that size and use it, it demands a const size that apparently needs to be set at compiling. Although at some point I somehow managed to make it compile with the user input variable size for array size, I have no idea why. It got very upset some days later and redlined it hard. Somehow I had managed to make some sort of loophole around it. Maybe it treated it as heap allocated somehow. It would be really nice to get those turned into stack allocated arrays though, because every function used all the data in the container. Maybe if there was a good idea of the limits of the data set, but I find that the programs I've written to help with some stuff should allow quite big sets, even though I might use it for small sets especially in testing. In general, I find that most if not all of my programs revolve around asking user input and then calculating something. Programming would be so nice if it was done without user inputs. Especially Rust would be nice to use without.
hey man. i have a question about skillshare. i'd like to know a bit what kinda stuff is on there without registrating becuase i don't wanna waste the 2 free months because i currently don't have a lot of time yet. so can you quickly go there and browse for dsp courses for me to inform me if there's some stuff about dsp programming? or things like filter design for audio filters
HELP, super confused on how the data[i] = 2; works. this is a class called data, which has a private memeber m_Data[s]. the overloaded operator [ ] simply returns the current value of m_Data. should the way to fill the array not be array data; int* Ptr = data.Data; ptr [0] = 0; maybe this is also wrong as you are accessing the private data member. As you can see i am stumpted. i would assume having a public fuction like void fill_array (size_t size, T data_value) { m_Data[size] = data_value; } Many thanks for any and all help
You are allowed to modify a private data member directly from a function that is external to the class (i.e., non-member) as long as you do that through a public member-function which returns a reference (or pointer) to the private data-member..
Thanks for watching! Don't forget that the first 1000 people who click the link will get 2 free months of Skillshare Premium: skl.sh/thechernoproject10
Watched your all C++ vidoes.. those are awesome.. thanks for this video waiting for STL from long time
Damn I cannot take it.
Not able to sign up
Just wanna say thank you so much for the Skillshare offer.
Can't wait to study more programming and game design! :D
Thanks for this, I've been wanting to try it! Got in on it!
Suggestion: video on CMAKE, makefiles, etc
YES PLEASE
Somebody asks that on almost every one of those videos and I’m pretty sure the reason he hasn’t done a video on the subject is because Makefiles, etc., aren’t part of the C++ language, and this is a C++ language tutorial. Plus, he uses visual studio, which doesn’t use Makefiles, so it would be pointless.
@@jscorpio1987 you could say it's a null pointer
He doesnt even use cmake and makefile is not usefull to him since he uses windows+vstudio only
Those are poor excuses for not doing it. Plenty of projects that use C++ make use of cmake or make files. He probably runs into them quite a bit, especially with open source projects.
Waiting for data structures for a looooong time super excited for this series
Suggestion: linked lists then binary trees.
My knowledge of this area is a little patchy and hearing a second expert explanation of a topic is always welcome.
cool
I agree with this order, binary trees are in of themselves a linked list. Hopefully he'll explain doubly, single, and circular linked lists sometime soon.
@@nallid7357 Not all. You can implement binary heap with an array.
Love raw breakdowns like this. This quality is what makes your channel unique 👍
i love you for doing this. 1 BIG recommedation is to move this videos to early parts of the playlist. many thanks. love your work!
Definitely need video on implementing iterator please
A really super simple forward iterator is literally just a pointer. So part of your goal is already done.
@@jamesmnguyen Yeah, but that only works for two data structures, vector and array, and the latter works because arrays decay into pointers. Implementing iterators for anything else is more complicated.
@@oracleoftroy Iterators for linked lists are also pretty easy. It gets harder for trees though, because you need to figure out the logic to access every element in the right order. Especially if it is a search tree, where the order is important
@@maksymiliank5135 ... which is indeed one good reason to look forward for a tutorial from The Cherno. That promises to be quite exciting.
Thanks for this series. The stack and heap allocation just made me smile.
Awesome man! Very glad you opted to start delving into data structures and algorithms in your C++ vids! Very much looking forward to more of these! Thanks so much.
I'm glad you're doing this series lmao. I took a data structures course at my university last year, and now I can keep myself refreshed on the material through these videos so I don't forget all these concepts
That "noise" at the top is very useful. It allows you to write things like using container = std::array; container x; memset(x.data(), 0, x.size() * sizeof(container::value_type));
Then when you need to change int to uint64_t or uint8_t, you only need to change it in one place. Putting sizeof(int) in that memset is buffer overflow waiting to happen.
I've wanted to this exact thing for a long time and was never able to fit the pieces together. Thank you. :D
Love this data structure focused video in the C++ series. Please keep the coming!
FINALLY!! I've been waiting for a DATA STRUCTURES series for what feels like ages. Much appreciated!!
Simply brilliant, Cherno! Keep them coming!
This series is super helpfull! :)
Edit: Also, the way Cherno explains the things (dissected and explained step by step, from basic functionality too the more complex results) is so much better then most written documentation you can find..
Thank you Cherno! was helpful as always.
Thank you so much ! Looking forward for the iteraror implementation. Also, I'd like to see you talk about boost library, more specifically boost::bind methods (also also, I believe they have been integrated into STD by now)
glad you're making data structs & algos series.
would also be good to mention using arrays unless you need optimization is bad practice, and more generally optimizing before you need to. and it would be nice if you go into some of the nitty gritty details about why there's an overhead from not keeping your data contiguous; it's not self evident, and especially mysterious if you know your programs use virtual memory.
My very favourite topic in C++ : data structures. Thank you so looking forward to it.
I was waiting soo eagerly for this 🙏🏼 your videos have become my bread butter daily these days haha.
Thanks so much for sharing all your knowledge cherno!
I am an undergraduate student. I already love your content and find it really inspiring. But can you please do more content related to basics and Data Structures?
Could you do a video on ideas for projects beginners/intermediate C++ programmers could do to add on to their resume? Currently going into my 3rd year in college, and I'm looking to apply for internships for next summer, but I don't really have any projects to put on my resume nor do I know where to start.
How is it going
Waited for this for so long! Looking forward.
Love this style where the video zooms in on the code and it is easier to see.👍
Thank you So Much , you are the best channel i've seen ... you are beyond professional. You are my inspiration in learning c++ and, i hope you keep making videos, love you Cherno.
In case you need it, here is the source code of the array data structure:
#include
#include
template
class Array{
public:
constexpr size_t Size() const {
return S;
}
T& operator[](size_t index){
return m_Data[index];
}
const T& operator[](size_t index) const{
return m_Data[index];
}
T* Data(){
return m_Data;
}
const T* Data() const {
return m_Data;
}
private:
T m_Data[S];
};
int main(){
Array data;
data[0] = "Cherno";
data[1] = "C++";
data[2] = "We";
data[3] = "Love";
data[4] = "Programming!";
for(size_t i = 0; i
Great videos!!!
Could you make a video about UNIT TESTs in C++?
up
Yes please!
Awesome! Can't wait to see the next DS 😍
best cover of data structure. Thanks for sharing
Honestly, I did not touch c++ since 3rd year at uni. This video made ne remember a lot about c++ and tought me more about it than 2 hours at uni ever did)
Def subscribed coaus of that. Even though I don't use c++ at work)
Suggestion: templated version of segment tree.
I know it's not that important but if you find time, it'll be pretty interesting to do.
I'm really gonna LOVE this! I was always trying to implement different STL classes that I use and love myself. And also to expand and add upon them. My favourite ones were String and List(dynamic array).
Thanks a lot for your great content Yan 💙💙
std::list is not a dynamic array ;)
I dislike all those who hit the dislike button. Thanks for that beautiful lesson Cherno!
Definitely gave me more insight regarding OOP and templates!
Would love it if you would do more of these!
Yes more of this please
Thanks, Cherno! Your channel is a real treasure)
A few remarks
The STL array has its underlying array field public to allow for aggregate initialization, like you can do with a plain array.
All the type members like pointer, const_iterator, etc. are actually required by the standard, not just in MSVC implementation
Cherno this C++ series is legendary
Loved your videos. Learning so much.
Great Great Great! video. What a great video to watch while drinking my morning coffee ;)
This was so helpful! Thanks
If T is an user defined type with no default constructor then this array class would complain about it
Awesome sir, Thanks. It helps a lot.
Thank you so much 🙂. What a great series of c++..
Thank you Cherno. Admire your work.
I found this very useful, thank you!
you know , I had sworn that I will never understand loops but after watching your video on the topic , I am on the safe side now, I guess, Thanks man....
AVL trees intrigue me and I'd love to see them in a future video
Nice, would be lovely to see you cover tree-based data structures. probably after linked lists.
I'd love to see a simple compiler series using flex and bison to generate a abstract syntax tree that is class based. Then see it in action. An AST that can be reused in other languages you work on.
thanks for the explanation😊
14:44 Why empty() always returns false in MSVC STL?
I'm getting "true" from empty() on std::array with MSVC. So there's probably a different version of that function somewhere in the code, or something like that.
While arrays may be easy to deal with, I would certainly like to see you implement some much more complex types like tuple. XD
Also, those size_type things are required by the standard, so that template meta-programming on std containers is easier.
std::array are implemented as a struct containing a public member of the array, which makes the struct an aggregate, that enables the aggregate initialization syntax (like std::array array{ 0,1,2,3,4 };) without requiring any constructor to be implemented manually.
How is a tuple complex?
@@sebastiangudino9377 Try implement a tuple type yourself and you'll see.
Thank you
WE WANT MORE DATA STRUCT VIDEOS les goo
Does anyone know which theme he uses for Visual Studio?
That is exactly what i want to learn.
Careful with alloca(), it is non-standard (even in C) I think it's only standardized by POSIX, which makes sense because Microsoft's version easily breaks in try/catch blocks. alloca() does have its uses, but if you can get away with a stack array or a SmallVector, you probably want to use that instead.
The content....Love it 🔥
what does “runtime value” mean? 9:12
People, never ever in a million years do a memset call like was shown in this video. That is allowing external code to operate in the private parts of the class. Place the memory setting code INSIDE the class. That code there I would have marked as needs work if I ever saw it in a pull request.
The problem I had with these types of structures is that it becomes annoying to pass the arrays around in functions. since Array is a completely different type than Array unless there's some magical c++ way to do it...
I have been using codeblocks and GNU GCC compiler, and it allows sth like this:
int main()
{
int n;
std::cin >> n;
int array[n];
std::cout
Why doesnt he use typename @10:14?
Typename is for specifying a custom type, he doesn't need a type parameter as it will always be an int array (if it was customizable that would be done), he wants to specify a custom SIZE as an int/preferably size_t so that is parameterized in the template args
Would love to see videos implementing data structures of other STL containers like vectors and strings with things such as iterators within them in the future. Anyway, great video :)
Looking forward to Cherno making his own mini-stl
the::cherno::libs::standard::stl
More videos like this pls pls!!!!!!!!!
The alloca has a larger issue there. Unrelated to performance. The problem is that it will be freed after the constructor retutn/exit the scope of the function. Meaning you can not use it like that. Only way to get around that is to make the allocation in the scope where the object is created.
If you do it like you did it might compile and work in some cases. But in reality you are using stack memory that the program sees as free and might be occupied by other stuff. So it's an undefined behavior.
Alloca is awesome, but dangerous if used wrong like that. Should make eha clear.
Great refresher!!!♡☆
dude you are a god
Great video! Suggestion: I would really like to know what constexpr and noexcept are...
Live demos are cool! Hopefully I will see you on some gamedev/cpp conference as a speaker.
Great Video! I just made a dynamic array and a doubly linked list last semester. It is so much harder than it oringinally sounded. Would love to see how to create a (un)ordered (multi)map or a priority tree of some sort! Thanks again! :)
Suggestion: I know this isn't a data structure, but somewhat related. Could you talk about endianness and how to deal with it? I suppose this is more to do with data punning than anything, but as a firmware engineer working in c, it would be nice to know how one deals with it in c++.
We can technically define:
const int size = 7;
And before using it to define an array, we can change its value via a pointer like this:
int c = 5;
const int a(c);
cin >> (*(&c + 1));
int array[a]
//////////
Now I know that array size must be declared at compile time but this just works... I wonder what strange behaviours will be caused by this hmmmmm...
At 18:40, isn't
if(index >= S) {...}
much simpler and easier to read than
if(!(index < S)) {...}
The TAs at my Data Structures class allocate *everything* in the heap, even objects which already allocate to the heap by themselves. And they don't even care about releasing the used memory before ending the program.
The program may compile and run one way or the other, but I think that's a very bad habit (and bad habits die hard). At least they could tell us we shouldn't do that in production environments or something like that.
Those people usually come from Java where you "new" everything and never delete
Waiting for this
I find it interesting that the debugbreak doesn't work on the const reference of our array.
Hey how do I add external libraries in visual studio please ...
Please cover unit tests and tuples implementation.
Would you make a video about constexpr and noexcept
Great, no 2-minute long intro that has nothing to do with the video, great!
Can't you use const for the size issue ? You said template is the only solution for that issue.
Continue this, Implement other data structures like List Set Map Binary Tree
In a case where a class constructor takes a pointer of data in parameter and stores it in a class member, I can't quite find a good way to deal with the nature of the pointer. Is there a way to tell if it was stack allocated or heap allocated? The main use case is for a class interface for users who don't exactly know how the class is implemented. If the data is stack allocated and passed to an instanced of the class which is heap allocated, the class should copy the data and delete it in its destructor. But if the data is already heap allocated copying it is a waste of performance and memory. Is there a prefered way for this kind of situation? I am missing an abvious poin?
You should copy the object regardless of whether it is stack- or heap-allocated. Even if the data is allocated on the heap, your class is now dependend on data that it does not own. Someone else will eventually have to delete that data and you might be left with an invalid pointer.
However, this could also be solved with an std::shared_ptr. The shared pointer would guarantee that the data can not be deleted while your class is still using it. The shared pointer only allows for heap-allocated objects though, so you option 1 might be your only option.
Finally, data structures!
which IDE and theme you use
Exception handling, and whether or not to use them please :)
Cherno, can you please make a video to explain the difference between constexpr and const ? Thank you ...
Awesome! Would love to see more data structure videos :)
Very good content as always. In one of the first videos (video 2 of C++ Series) I downloaded your vs settings. They seems to have changed. Do you update the link or give a one with your updated settings?
I dig arrays but it feels like whenever I'm writing a program (mind you I'm not a programmer by education or profession, I just have had some classes in my degree), it's a case where you ask the user the size of the container (or the data set to be more accurate) if you're not reading it from a file. And c++ doesn't let me get that size, then create an array with that size and use it, it demands a const size that apparently needs to be set at compiling.
Although at some point I somehow managed to make it compile with the user input variable size for array size, I have no idea why. It got very upset some days later and redlined it hard. Somehow I had managed to make some sort of loophole around it. Maybe it treated it as heap allocated somehow.
It would be really nice to get those turned into stack allocated arrays though, because every function used all the data in the container.
Maybe if there was a good idea of the limits of the data set, but I find that the programs I've written to help with some stuff should allow quite big sets, even though I might use it for small sets especially in testing.
In general, I find that most if not all of my programs revolve around asking user input and then calculating something. Programming would be so nice if it was done without user inputs. Especially Rust would be nice to use without.
_malloca should be used, it is a version of alloca with security enhancements.
hey man. i have a question about skillshare. i'd like to know a bit what kinda stuff is on there without registrating becuase i don't wanna waste the 2 free months because i currently don't have a lot of time yet. so can you quickly go there and browse for dsp courses for me to inform me if there's some stuff about dsp programming? or things like filter design for audio filters
Hey just wondering if I can get your visual studio config in terms of colors? Hope you understand what I mean
thanks for the video
HELP, super confused on how the data[i] = 2; works.
this is a class called data, which has a private memeber m_Data[s].
the overloaded operator [ ] simply returns the current value of m_Data.
should the way to fill the array not be
array data;
int* Ptr = data.Data;
ptr [0] = 0; maybe this is also wrong as you are accessing the private data member.
As you can see i am stumpted. i would assume having a public fuction like
void fill_array (size_t size, T data_value)
{
m_Data[size] = data_value;
}
Many thanks for any and all help
You are allowed to modify a private data member directly from a function that is external to the class (i.e., non-member) as long as you do that through a public member-function which returns a reference (or pointer) to the private data-member..