Member Initializer Lists in C++ (Constructor Initializer List)

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


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

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

watched this earlier today and have just written my first constructor initializer list
i confess, i'm feeling pretty gangster right now

samdavepollard
Автор

Hey Cherno. Just want to say that this series is one of the best I've seen on youtube. I've been in the industry for about a year now but having refreshers like these are always good. Like I haven't actually thought about why I use member initializer lists in years since I've just gotten in the habit of doing so. I'm looking forward to more videos so that I can fully recommend this series to more novice programmers.

DaRealPielover
Автор

Lost it at the closed captions.

"Hello guys my name is a cheddar"

LoxagosSnake
Автор

I didn't realize this actually had performance benefits.

When I first saw them, I thought they were just a nifty way of writing constructors.

Plasticcaz
Автор

Also you cant initialize *const* members without using "Member initializer".

Naif
Автор

Mind blown @The Cherno. As I said in a earlier video and will say now you are the best C++ teacher and course on Youtube. To the way you describe subjects to asking the biggest question of why you would need to use them and giving an example. To be honest I thought I would never be able to learn programming and actually learning the materials until I went to college and forced myself but I was wrong. I wish I found this channel sooner than I did. Big props to you though in helping everyone and making this playlist. I can't wait to learn more from the rest of the videos and then try and make a simple project later on.

drkerberos
Автор

Member Initializer List allows you to use references as properites of a class. (Without using it, you cannot do it because references has to have assigned values while being created.)

hexi
Автор

Holy cow. It's like a constant stream of videos!! I use some of your videos as reference for my high school classes. Cheers!

zfighter
Автор

Don't forget Member Initializer Lists can also be used for initializing const member variables as well!

joshs
Автор

Cherno makes both C++ and teaching C++ look easy
Heck, been reading some Stanley Lippman and that dork just sux ass explaining, and the book is a fucking minotaur maze. While Chemo makes it crystal clear and enjoyable. I just feel like I'm having a great company and we speak same language. I feel so much better watching these. Thank you, Cherno, you bring a lot to this world

GreenFlame
Автор

Incredible video series that will remain relevant for years to come. Nice work man, appreciate it.

TheKingofkatz
Автор

First of all really thank your for all the videos. Even though the most concepts may be known by a lot of people already, it's interesting to see what happens behind the scenes. For example the Initializer lists. I knew they would be better in terms of performance in some situations.. but I never actually knew why and when especially. I didn't even feel the need to look it up. But I just like to know things like those, so these videos are really interesting and helping me out!

And I like it, you are not discriminating primitive types nor classes!

BOTHLine
Автор

Great work! I would like add two things though, I am not really sure why 2:48 "make sure you always initialize your variables in the same order that they are declared in when you declared them as members" If the order of initialization only matters on the order of member declaration when using initialization list it should not matter in which order I initialized them, it would matter if I had not used initializer list and initialized inside curly braces. Second the main reason that initialization by list is better is that it only calls the constructor but if I initialize inside curly braces a copy assignment is performed after the constructor. Scott meyers 55 ways item 4. Again keep up the good work.

farsanrashid
Автор

amazing explaination and that is amazing effect there when you said like and the like button actually glowed, woah mindblown

b__aditidonode
Автор

This video should come before the virtual functions video!

lucha
Автор

i didnt know that. thanks, ive watched alot of your videos you are doing great work. cheers

legendarytwister
Автор

Wanted to say thanks! Your videos are great and are a huge help to me in understanding C++.

allenvicencio
Автор

I just want to thanks for this great content
one of the best c++ courses on YouTube

mamoudgad
Автор

"hey little guys my name is a chadder and welcome back to my say plus plus series" xD

wearyadventurer
Автор

@TheChernoProject Man! You rock!!!. I was having trouble understanding this but you made it so simple with ur examples. Thanks!

samarthsrivastava