Single Inheritance Deep Dive: Examples + Code | C++ Tutorials for Beginners #38
Vložit
- čas přidán 13. 05. 2020
- ►Source Code & Resources: codewithharry.com/videos/cpp-...
►This video is a part of my C++ playlist: • C++ Tutorials In Hindi
►Checkout my English channel here: / programmingwithharry
►Click here to subscribe - / @codewithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Python Tutorial In Hin...
►Python Complete Course In Hindi - • Python Tutorials For A...
►C Language Complete Course In Hindi -
• C Language Tutorials I...
►JavaScript Complete Course In Hindi -
• JavaScript Tutorials I...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Django Complete Course In Hindi -
• Python Django Tutorial...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithharry.com
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here
One of the best coding tultor in the world ❤️
Turtle 🐢
For anyone wondering why we were able to assign a value to data1(an uninherited memeber). When you create an object of a derived class, even if a private member (data1) of the base class is not inherited, compiler still allocates memory to it. That's why calling the setData() function works, since memory has been allocated and now it can change the value stored in that memory to whatever (data1 = 10 ) in this case.
Plz explain this simple words please
@@MOHIT836 Wrong teaching that private members are never inherited.
Correct thing:
Private members are also inherited, however, even though private members of the base class are inherited by the derived class, they are not accessible directly. They can be accessed indirectly through public or protected member functions of the base class.
This ensures encapsulation, protecting the internal state of the base class while allowing controlled access through member functions.
By understanding this, you can see how C++ promotes encapsulation and data hiding, ensuring that the derived class can only interact with the base class's private data in a controlled manner.
This is also the reason why a base constructor is invoked, when the constructor of a derived class is invoked. Constructors are generally used to assign values to private data members.
Properly calling the base class constructor ensures that all inherited members are correctly initialized, maintaining the integrity and consistency of the derived objects. Failing to do so can result in uninitialized data, leading to undefined behavior and serious logical errors in the program.
16:26 No, as its an private member of base class so we can't change its value directly,
but we can make a public member in base class which changes it's value and can use this member by inheritance in another class
its already there
base class ka object create krke agr setData() run kre to grabage value aa rhi he aesa kyu huva (visibliity mode = public )
@@vivekkotecha7818 send all code to see
Woow perfect, that's why classroom lectures are boring .
bro we can directly set data1 by just making friend class in base class of drived class.
It is my first time studying OOP and I find inheritance easy! Came here after C. Thank you Harry bhai.
same
For me it's easier than Constructor
16:25 yeah!!! by simply creating a base member function which takes an integer argument.
yes bro ofcourse
Bro can you please elaborate it, I'm a little bit confused
Harry bhaiyya ne kaha tha k ye topic bhot difficult lagta hai logo ko but unhone jitni acche se samjhaya hai laga hi nhi kahi se bhi difficult 😇
In 2020, there are 303k subscribers now its 5.25 million this is our love to you Harry bhai, Thank you for such a valuable content.
Sir ! You are great, and aapki videos bhot achhi hai, mene bhot saare tutorials dekhe hai pr aap jesa koi nhi, is playlist ne meri bhot help kri hai C++ ko sikhne me.
Aap is course ko continue kriye, eagerly waiting for your new video on this playlist
HARRY BHAI AAP CODING BAHUT EASY & SAMAJH ME AYE AISA SIKHATE HO 😘😍
Harry bhai your harding working on these tutorials, You're providing us a better and high quality courses that is totally practical and technical that we want.
Thank you so much and keep updating us more!
People getting confused so as to when do we need to use Default constructor or not can refer this:
/*
We need to compulsorily have a default blank constructor in the following cases:
1. Creating an obj such that it is uninitialised at the time of declaration (Not passing parameters to Constructor).
eg- Cricketer C; // creating an unitialised obj of the class Cricketer
2. When a child class is inheriting methods and data members from a parent class, the parent class must contain an empty default constructor.
eg- in above code, its compulsory for class Cricketer to have a default constructor.
*/
/*
We can avoid having a default blank constructor in the following cases:
1. We are initialising our obj at the time of Declaration only.
eg- in above code if we write the following
Coach Rahul("Rahul Dravid");
OR
Coach Rahul = Coach("Rahul Dravid");
Then we don't need to have an empty default constructor
*/
Thanks bro
Bro pls tell from where to practice c++
Thank youuu so muchh!!!! :)
thankyou
Nicee
Thank you Harry Bhai for this playlist. Your support and guidance is really very helpful ❤️❤️🔥
thx u so much sir!!!!!!!!!!!!!!!!!!, to continue c++ course...i do your course with full of fun & every point u will clear inside your video.
Thankyou Harry sir , I am really happy to have teachers like you🙏🏼🙏🏼
16:26 yes we can set data1 in display as well as process function in place of getdata1(), just we need to make friend class drived in base class and thats all we need to do .
that was really confusing at first but when i rewatched it again and again, i grasped the whole point
You can set data1 by making a public function in base class which will accept an argument and set that to data 1
Truly appreciate ur teaching style.💯💯💯💯💯💯💯💯
Your teaching method is always awesome....It's really rock and thanks for helping students...Keep it up bro...And thank you very much for such kind of Playlist.....
Sis do you know about python???
Hello Harry bhai, first of all thank you to give me a way to learn C++, before seen u r videos a i have an no knowledge about c++. and also think how to improve and learn. After that now i have completed 38 part today and getting knowledge and code running ability. Also believe that after complete all part i shall be getting more knowledge, code running ability. Thank you stay with us ♥♥♥
the way you explain is appreciable ;)
Your Teaching method is beyond awesome sir
Thankyou Everything is clear 🤩 and going great
Really sir you have changed my life❣️
Thank you, Harry bhai! Watching it in 2022!
They are extremely helpful and things were clear
Harry bhai aapka ye C++ course such me bohat helpful hain...
hard tha bhai ap ne bahut asan kardiya bhai...dil se thank you for such a beautiful playlist
Wonderfull lecture. Thanku so much sir.
Harry bhaiya great video with clearance
Without lying :- meko constructor ke pehle ke oops meh maja nahi aaraha tha video concept samj aaraha tha orr phir ab inheritance meh orr bhi maja aaraha hai
very nice video, helped me understand concept of inheritance very easily
Harry bhai bahut achhe video banate ho ❤🙌 keep it up...! For us.. 🤟ty bhai❤❤
THANKYOUUU SO MUCHH!!!! ✨✨
I have seen all your videos till here.. They are the best 🔥🔥🔥🥰🥰🥰💖💖
easy understanding of concepts of oops and C++
Yes , we can change Data1 value by the creating Member function.
you are amazing harry bhai! keep this up! :)
Your videos are very helpful for understanding C++.
Thank you Bro.
harry bia ess course koe app a to z tkk complete krnna...muzze apkki video bhut intresting lgti hee...bakki youtube teachers se...REALLY TRUE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Harry is genius and excellent coder in you tube.
Oh man! What a like to dislike ratio! Nice! It's more than 2 hundred. Great job harry bhaiya!
Yes I am Learning C++ very fast than never before just because of you
wow this is osm harry bhaii inheritance is hard for me but after watch this tutorial this looks soo soo easy this is osm thank you
Very helpful content...Keep uploading such type of content.....Thank You
bahut aache se samjh aarahi hai
Bhaiya loving your lectures , Thankyou for all this to us .
Thanks Harry vai for this classs
Thanks, You're an amazing programing teacher ,I love you❤️
Thank you Thank-you so much sir ❤️❤️❤️
bhaiya app ko mai dil se naman karta hu app jaise educators ho baber bhaiya jaise jeeny mam aman bhaiya app logo ke wajah se hum lower middle class wale yeah afford kar patea hai
thank you so much harry !!!
Bhai thank You yar .... Itna help hota h apke channel se vdo dekh k 🥰🥰🥰
Best tutorials!
Harry bhai your teaching techniques are just awesome...maza aa gaya..
awesome video harry bhai
we can set data one value by defining a method publicly in base class, we can access that in the main( ) by calling it
👍👍👍👍👍you are a very good teacher👍
Thanks Harry Bhaiya
Fabulous bhaiya..
Waiting for next one
16:26 data1 ko base class k public constructor m set kar skte hain ...aur phir main method m woh hi constructor invoke kar lenge.
Harry bhai iss lecture mai jo aapne smjhaya hai na ooo bahut jyada OP hai.Thank you sir....
understandable lecture for coding.
thanku
I really enjoyed it very much Harry bhai ❣️❣️❣️💞💞💞
Thank you, thank you, thank you ❤️❤️🥰
Thanks for making this tutorial for beginners,
This videos is proved very helpful for me because i don't know any programing language but this videos make a very strong base in programming language thanks 🫂 sir🙏
You make it easy ..👍
your teaching is so good and congrats for 2M ❤ ❤
Nice sir...... I love the course...
Very helpful harry bhai👌🏾👌🏾👌🏾👌🏾
Bht axha smja rha bhaii ap thnxxx
Very helpful tutorial Harry Bhai.
Thankyou bhaiya going on the way with your videos
Yes, we can set data1 indirectly with the help of methods or even constructors
Excellent!
brother 999K .. 1M hone wale hai. congrats harry bhai
You are best coder in you tube.
Hari bhai Dil se ❤️❤️❤️
I'm so comfortable in your teaching style so please java ka full course le aao
Join my robtics club and ethical hacker clubb
@@xompguru720 hahhahhahhahahhah
You are awesom harry bhai
Thanks for free knowledge
Thanks HarryBhai!
16:29 As data1 is private so we can't be able to use it outside the class. In that case, we use getfunction() or move the data1 to public instead of private.
Harry bhai bhut he completed videos ha...
Super fantastic video
Awesome explaining sir ji
Very helpful
Thank you 😊
bhai bhot bdiya samjhaya h
samaj aa gya bro.
At 16:26 we can set data 1 in setdata(); of derived class but this value of data 1 is not affected in base class , as WE HAVE MODIFIED DATA1 IN DERIVED NOT IN BASE.
Very very very excellent and great
Job sirrrrrr
Thankyou so much ❤️
yes harry bhai, sab samjh me aaraha hai jo aap padhaa rahe ho
Awesome video😎😎👍👍
21:30 very helpful harry bhai❤
Videos are helpful Bhai !!
it is very helpful for everybody
Thank you Harry Bro ❤️❤️
Thank you Harry bhai
Bahot achha
*_AMZING COURSE_*