Classes Part 22 - Curly brace versus parenthesis and std::initializer_list| Modern cpp Series Ep. 59
Mike Shah
0:00 / 0:00
Classes Part 22 - Curly brace versus parenthesis and std::initializer_list| Modern cpp Series Ep. 59
12 629 просмотров · 4 года назад
Mike Shah
41,6 тыс. подписчиков
12 629 просмотров · 4 года назад
►Full C++ Series Playlist: • The C++ Programming Language
►Find full courses on: https://courses.mshah.io/
►Join as Member to Support the channel: / @mikeshah
►Lesson Description: In this lesson I show you three different ways to initialize a variable (the fourth would be to perhaps not initialize the variable which is bad practice). In C++ there is a difference between using curly braces and parenthesis. Parenthesis will call the constructor and setup any arguments. Curly braces may also call the right constructor, but will also prevent narrowing (i.e. conversion of types). In addition, using curly braces to initialize an object will use a constructor with an std::initializer_list if one is defined.
►YouTube Channel: / mikeshah
►Please like and subscribe to help the channel!