Тёмный

Initializer List In C++ 

CppNuts
Подписаться 77 тыс.
Просмотров 27 тыс.
50% 1

JOIN ME
-----
RU-vid 🎬 / @cppnuts
Patreon 🚀 / cppnuts
COMPLETE PLAYLIST
------------
C++ Tutorial For Beginners: • Introduction To C++
STL (Standard Template Library): • STL In C++
ThreadIng In C++: • Multithreading In C++
Data Structures: • Data Structure
Algorithms: • Binary Search
Design Patterns: • Factory Design Pattern...
Smart Pointers: • Smart Pointer In C++
C++14: • Digit Separator In C++
C++17: • std string_view in C++...
C++ All Type Casts: • static_cast In C++
INTERVIEW PLAYLIST
------------
C++ Interview Q&A: • Structural Padding & P...
C++ Interview Q&A For Experienced: • How delete[] Knows How...
Linked List Interview Questions: • Find Kth Node From Bac...
BST Interview Questions: • Search Element In Bina...
Array Interview Questions: • Reverse An Array
String Interview Questions: • Check String Is Palind...
Bit Manipulation Questions: • Find Set Bit In Intege...
Binary Tree Interview Question: • Invert Binary Tree
Sorting Algorithms: • Bubble Sort
C++ MCQ: • Video
C MCQ: • What printf returns af...
C Interview Questions: • Designated Initializat...
QUICK SHORT VIDEOS
-------------
C++ Short : • C++ Short Videos
C Short : • Shorts C Programming MCQ
What Are All Those Places Where Initializer List Is Must In C++?
• What Are All Those Pla...
In this video we will learn what is the use of member initialiser list in c++ programming language.
There few points about the same as follows:
1. Constructors And Member Initializer Lists C++
2. This is used to initialize data members of classes.
Two ways are there to do this.
1. Using {} this is uniform initialization and should be preferred.
2. Using ()
#cpp #tutorial #programming #coding #computerscience #softwareengineering

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@krishnakumar-pv1hb
@krishnakumar-pv1hb 18 дней назад
During member initialisation don't use (), the compiler will give a level 2 warning. It's better to use { }
@crazymemes4080
@crazymemes4080 5 месяцев назад
have you ever noticed this initializer list in LEETCODE question if you check linked list question.
@yc2158
@yc2158 6 лет назад
Do we have any specific name for the " : " which is used for initializing data members?
@yc2158
@yc2158 6 лет назад
I have to tell this "U R THE BEST". U made it simple n easy.😍👍
@CppNuts
@CppNuts 6 лет назад
As you already be knowing, it is collon, and thats the syntax for writing initializer list.
@CppNuts
@CppNuts 6 лет назад
Thank you so much.. :)
@RAMANKUMAR-xl4pr
@RAMANKUMAR-xl4pr 6 лет назад
thanks for your knowledge sir, You made it very simple and easy. Thanks
@CppNuts
@CppNuts 6 лет назад
Thanks dude!!!
@mapradnardev
@mapradnardev 3 года назад
when i use curely braces Base(int a):x{a} it is throwing error.Using curely braces instead of paranthesis is compiler dependent or what?
@CppNuts
@CppNuts 3 года назад
Yes upgrade to new compiler.
@thilakraj4207
@thilakraj4207 2 года назад
sir could you explain the use of '(int)x' which you used in the program?....I am not aware of that.
@CppNuts
@CppNuts 2 года назад
It’s called typecast.
@benjahnz
@benjahnz 4 года назад
A great tutrial, clear and concise. Thanks!
@maverick7615
@maverick7615 6 лет назад
omg awesome video! you have made everything become crystal clear thanks man!!
@CppNuts
@CppNuts 6 лет назад
You are most welcome dude.. :)
@joelcurtis562
@joelcurtis562 4 года назад
Why use a member initializer list at all? It seems like the way you initialized the member variable x to start with was very intuitive and natural. This way just seems unnecessarily complicated, so I am wondering what is the payoff of having to learn a whole new syntax when a more familiar one seems to work just fine?
@CppNuts
@CppNuts 4 года назад
Hi Joel, good that you asked, here is the link where i have explained what are the different places where you will use initializer list. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vmMKXLuDgYQ.html
@dokodiaries
@dokodiaries 4 года назад
@CppNuts I think you are using sublime text how to setup it for ubuntu
@CppNuts
@CppNuts 4 года назад
I cannot explain it here, try Google and I am sure you will get. It`s pretty common
@charmingcat494
@charmingcat494 2 года назад
Hi Rupesh, I am using this textbook and a piece of code has me confused and you are the only person I could think of to ask. It seems like an object is being initialized within a function inside a class. is this possible? here is the code snippet below: void addInterest(int rate, int divisor) //function within DollarAmount class { DollarAmount interest { //DollarAmount is class name (is interest an object of DollarAmount?) (amount * rate + divisor / 2) /divisor }; //is this an initialization of interest? add(interest); } the book i am using is deitel c++ how to program and this is the example class given in chapter 5.
@DFsdf3443d
@DFsdf3443d 5 лет назад
but what if your member variable is an aggregate, wont it use aggregate initialization then? (which does allows narrowing - as far as i understand) im very confused about this whole initializer_list and aggregate initialization thing im sorry if this is completely wrong
@sallaklamhayyen9876
@sallaklamhayyen9876 2 года назад
thank you
@CppNuts
@CppNuts 2 года назад
Welcome
@bensalemmohamedabderrahman5844
@bensalemmohamedabderrahman5844 4 года назад
how can i initialize an array of objects when its private using the initialize list?
@konstantinrebrov675
@konstantinrebrov675 6 лет назад
Thank you dear sir!
@CppNuts
@CppNuts 6 лет назад
Welcome man!!
@janardhanreddy1180
@janardhanreddy1180 4 года назад
Awesome bro
@CppNuts
@CppNuts 4 года назад
Thanks..
@samchau8011
@samchau8011 3 года назад
There is no link in the description where initializer list has to be used! please post it!
@CppNuts
@CppNuts 3 года назад
Thanks Added in description. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vmMKXLuDgYQ.html
@videofountain
@videofountain 4 года назад
Is this the class constructor member initializer list? Perhaps the name of video should be changed. It was clear to hear you differentiate between initialization and assignment.
@CppNuts
@CppNuts 4 года назад
Initializer list is used to initialize data members.
@justinhendrix3969
@justinhendrix3969 Год назад
Awesome video
@ks-op8pe
@ks-op8pe 2 года назад
informative and concise. Thx!
@CppNuts
@CppNuts 2 года назад
Thanks
@bhupeshpattanaik7150
@bhupeshpattanaik7150 3 года назад
Where is that video that was mentioned to be in description, I found too many playlist links but no video link
@CppNuts
@CppNuts 3 года назад
Please mention what video?
@bhupeshpattanaik7150
@bhupeshpattanaik7150 3 года назад
@@CppNuts pls check this timestamp 6:31
@CppNuts
@CppNuts 3 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vmMKXLuDgYQ.html
@bhupeshpattanaik7150
@bhupeshpattanaik7150 3 года назад
@@CppNuts thanks .... 😊😀
@priteeshneema1574
@priteeshneema1574 5 лет назад
Thank You so Much Sir!! I DO HAVE ONE DOUBT: @5:01 u said {x=a} is assignment and x{a} is Initialisation. But when we do {x=a} doesnt it also perform the same operation as initialisation?
@indlamaheshkumarreddy9376
@indlamaheshkumarreddy9376 5 лет назад
it is initialisation using assignment operator
@aniketahir101
@aniketahir101 4 года назад
no..when object is constructed, compilers fills x with 0/garbage....later on the assignment is done x = a. Initialization list reduces one step...It directly initializes member with value when object is constructed.
@abrarulhaqshaik
@abrarulhaqshaik 3 года назад
@@aniketahir101 good comment. everything is clear now, thanks :)
@aniketahir101
@aniketahir101 3 года назад
@@abrarulhaqshaik great to know
Далее
Recursion In C++
7:49
Просмотров 7 тыс.
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
Просмотров 2 млн
ТАРАКАН
00:38
Просмотров 1,3 млн
This Pointer In C++
12:22
Просмотров 33 тыс.
Naming Things in Code
7:25
Просмотров 2,1 млн
Member Initializer Lists | C++ Tutorial
23:10
Просмотров 9 тыс.
31 nooby C++ habits you need to ditch
16:18
Просмотров 789 тыс.
Bit Fields In C & C++
20:36
Просмотров 22 тыс.
Virtual Function In C++
15:08
Просмотров 35 тыс.
Constructors In C++
12:49
Просмотров 27 тыс.