C++ How to pass arguments to class constructors [5]

preview_player
Показать описание
Learn all the ways to pass arguments to class constructors, including default arguments and using dynamic memory allocation.

We'll write a program to illustrate the concepts using Visual Studio 2022 C++ in this C++ tutorial for beginners.

// Join the new Programming for Everyone Community Forum:

// Learn More //

// Consider supporting this channel in multiple ways
Bitcoin: 177wfkQwzXiC8o2whQMVpSyuWUs95krKYB
Рекомендации по теме
Комментарии
Автор

Tank you for your "good work".
Best Regards, Jorge Carvalho

jorgealfredocarvalho
Автор

Do any of your videos explain constructors with member initializer lists. Something like this constructor. Triangle ( double b, double h) : base(b), height(h) { } I am just trying to understand it a little better. It seems like it is almost the same thing as in your video 1:07 mark. The only difference I see is you assign b to base and h to height in the body of the constructor and the version with the : does it in what I believe is called a member initializer list. Thanks

errik
Автор

I really appreciate how you show list initialization as well as (?) functional initialization. Couple of questions: does brace initialization warn of narrowing conversions when used in constructors? And does it also do the same when creating a dynamic object, i.e. using 'new'?

qcnck