Pheewwwww. This was exactly what was needed. A concise but complete explanation about how the two versions work. Especially that last point showing that the parameterized constructor gets called when the initializer_list version of a constructor does not exist!!
@MikeShah6 ай бұрын
Cheers!
@AlmondAxis987 Жыл бұрын
As a self-taught c++ programmer, this was really useful. I always wondered how libraries used curly braces for Container classes like rectangles, points, or RGBA colors. Thanks!
@MikeShah Жыл бұрын
Cheers!
@utkrystal457 ай бұрын
Well, I will surely recommend this video to my friends starting out with classes and want to have a deep understanding of initializer_list and curly braces. So, well taught by you, Sir!
@MikeShah7 ай бұрын
Cheers!
@lemuener7 ай бұрын
Thanks Mike for the Course I'm learning a lot of new things , very easy to understand your explanations... Thanks a lot.
@MikeShah7 ай бұрын
You are most welcome!
@dwolrdcojp2 жыл бұрын
Clear and easy to understand example. Thanks as always!
@MikeShah2 жыл бұрын
You are most welcome, thank you for the continued kind words!
@dhanushs18022 жыл бұрын
Very neatly explained as always. Thank You.
@MikeShah2 жыл бұрын
Cheers thank you for the kind words!
@propov18022 жыл бұрын
Hey, I got a question. At 2:27 Why do you print them by reference on primitive types? Wouldn't it be faster to print them by value?
@MikeShah2 жыл бұрын
For primitive types (i.e. a 4-byte int) you're probably right. :)
@blaisofotso34392 жыл бұрын
Thanks Mike for answering. Looking back at the code with your answer in mind, i have just realized that no member assignment was done in the constructor with parenthesis and if i am not wrong no elements have been saved(written) to m_data. How can the u object be constructed with parenthesis in this case then?
@MikeShah2 жыл бұрын
m_data will just be uninitialized. You should otherwise initialize it to some default value in the constructor if desired. In a few lessons I'll show how to do this with a delegate constructor. 😉
@blaisofotso34392 жыл бұрын
I am eager to know how it's done . Thank you ever so much
@sallaklamhayyen98762 жыл бұрын
great teacher + valuable content = thank you so much
@MikeShah2 жыл бұрын
Cheers! Thank you for the kind words!
@TheOldRoots Жыл бұрын
Do the curly braces only prevent narrowing, or any type conversion ? Like I understand why "int a{1.4}" would give an error since you are losing information in the conversion, but would float a{3} also give an error?
@MikeShah Жыл бұрын
The braces require type to match, so would need to do a{3.0f}; for instance.
@quoctrieu24132 жыл бұрын
Thank you very much !!! Thanks to your video i found the solution to assigne values to the obj of array (myseft-defined datatype) in this way: array obj = {val1, val2, ...}
@MikeShah2 жыл бұрын
You are most welcome!
@joebosah27272 жыл бұрын
Can’t get enough Carry on regardless Merci beaucoup
@MikeShah2 жыл бұрын
Derien mon ami! Cheers!
@brajrajsingh10015 ай бұрын
can anyone comment about the original souce code of various standard classes in c++ like class vector, class string , etc
@MikeShah5 ай бұрын
They're certainly interesting to look at and learn some tricks from -- and over time they're very useful to study more to understand exactly how things work. The STL's goal is to be portable, performant, and generic, so that may impact readability of the code however :)
@blaisofotso34392 жыл бұрын
Hallo Mike, why cant we print our data when we use parentheses? @12:39 / 15:52
@MikeShah2 жыл бұрын
Parenthesis use the constructor ;) So m_data does not have any elements to print out.
@manuvaad2 жыл бұрын
Thank you so much. Your lessons and talks are awesome as always!
@MikeShah2 жыл бұрын
Cheers, thank you for the kind words!
@reptilicusrex47482 жыл бұрын
Great explanation. Thanks.
@MikeShah2 жыл бұрын
Cheers!
@7denis712 жыл бұрын
Awesome! Your video lessons are awesome! :) Thank you for your doing this!
@MikeShah2 жыл бұрын
Thank you for the kind words!
@dolphin29542 жыл бұрын
Great video. Thanks.
@MikeShah2 жыл бұрын
Cheers!
@ThislsYusuf2 жыл бұрын
I got a stack-use-after-scope on address error when using AddressSanitizer. Is this a compiler bug? (It runs well without fsanitize) Thanks for the instruction!
@MikeShah2 жыл бұрын
Hard to know without seeing the code, do you have a timestamp in the video?
@ThislsYusuf2 жыл бұрын
@@MikeShah Thanks for the reply, it s the code I have after finishing the video. Hope pasting the code here isn't too cumbersome #include #include struct UDT{ UDT(std::initializer_list data) : m_data(data) { std::cout
@MikeShah2 жыл бұрын
@@ThislsYusuf Works fine for me on g++ and clang++, perhaps a compiler bug if you're on msvc? Try pasting in compilerexplorer.com and see if it works for some other compilers.