Single Inheritance Deep Dive: Examples + Code | C++ Tutorials for Beginners #38

Sdílet
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

Komentáře • 551

  • @prashantpanchal7746
    @prashantpanchal7746 Před 4 lety +156

    One of the best coding tultor in the world ❤️

    • @Kj89865
      @Kj89865 Před 6 měsíci +4

      Turtle 🐢

  • @sakshamchhatkuli271
    @sakshamchhatkuli271 Před rokem +46

    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.

    • @MOHIT836
      @MOHIT836 Před měsícem +1

      Plz explain this simple words please

    • @utsavseth6573
      @utsavseth6573 Před měsícem

      @@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.

  • @goodcake05
    @goodcake05 Před 3 lety +148

    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

    • @PawanBhakuni
      @PawanBhakuni Před 2 lety +9

      its already there

    • @vivekkotecha7818
      @vivekkotecha7818 Před 2 lety

      base class ka object create krke agr setData() run kre to grabage value aa rhi he aesa kyu huva (visibliity mode = public )

    • @vncode
      @vncode Před 2 lety

      @@vivekkotecha7818 send all code to see

    • @sauravmandal5
      @sauravmandal5 Před 2 lety +3

      Woow perfect, that's why classroom lectures are boring .

    • @godlovegaming5416
      @godlovegaming5416 Před rokem +2

      bro we can directly set data1 by just making friend class in base class of drived class.

  • @XeroGamingYT
    @XeroGamingYT Před 3 lety +58

    It is my first time studying OOP and I find inheritance easy! Came here after C. Thank you Harry bhai.

  • @thatowlfromhogwarts490
    @thatowlfromhogwarts490 Před 3 lety +20

    16:25 yeah!!! by simply creating a base member function which takes an integer argument.

  • @shubhamhire9390
    @shubhamhire9390 Před 3 lety +7

    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 😇

  • @TON-108
    @TON-108 Před 6 měsíci +4

    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.

  • @madhavpaliwal5548
    @madhavpaliwal5548 Před 4 lety +8

    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

  • @bestedmmusic512
    @bestedmmusic512 Před 4 lety +11

    HARRY BHAI AAP CODING BAHUT EASY & SAMAJH ME AYE AISA SIKHATE HO 😘😍

  • @ahmadqazi9291
    @ahmadqazi9291 Před 3 lety +4

    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!

  • @abhinavgarg5611
    @abhinavgarg5611 Před 2 lety +33

    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
    */

  • @jayeshbangar6243
    @jayeshbangar6243 Před 3 lety +3

    Thank you Harry Bhai for this playlist. Your support and guidance is really very helpful ❤️❤️🔥

  • @ManpreetSingh-nm2qd
    @ManpreetSingh-nm2qd Před 4 lety +4

    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.

  • @faltuaadmi6424
    @faltuaadmi6424 Před rokem +1

    Thankyou Harry sir , I am really happy to have teachers like you🙏🏼🙏🏼

  • @godlovegaming5416
    @godlovegaming5416 Před rokem +6

    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 .

  • @ronakbothra6371
    @ronakbothra6371 Před 3 lety +1

    that was really confusing at first but when i rewatched it again and again, i grasped the whole point

  • @priyanshusrivastava9379
    @priyanshusrivastava9379 Před 3 lety +8

    You can set data1 by making a public function in base class which will accept an argument and set that to data 1

  • @karanveersingh5535
    @karanveersingh5535 Před 3 lety +2

    Truly appreciate ur teaching style.💯💯💯💯💯💯💯💯

  • @soumyaranjanrout4366
    @soumyaranjanrout4366 Před 4 lety +20

    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.....

  • @WasimVlog1
    @WasimVlog1 Před 2 lety

    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 ♥♥♥

  • @anonymous_ghost_123
    @anonymous_ghost_123 Před rokem +1

    the way you explain is appreciable ;)

  • @animeboii-zv8vo
    @animeboii-zv8vo Před 3 lety +2

    Your Teaching method is beyond awesome sir

  • @nishantsingh8477
    @nishantsingh8477 Před 3 lety +1

    Thankyou Everything is clear 🤩 and going great

  • @roushansingh9936
    @roushansingh9936 Před 3 lety +3

    Really sir you have changed my life❣️

  • @muhammadareebkazmi9476

    Thank you, Harry bhai! Watching it in 2022!
    They are extremely helpful and things were clear

  • @sanjaymajumder2991
    @sanjaymajumder2991 Před 3 lety

    Harry bhai aapka ye C++ course such me bohat helpful hain...

  • @syedjuned842
    @syedjuned842 Před 2 lety +1

    hard tha bhai ap ne bahut asan kardiya bhai...dil se thank you for such a beautiful playlist

  • @-AATMA
    @-AATMA Před 6 měsíci +1

    Wonderfull lecture. Thanku so much sir.

  • @mohd.irfanlohar4544
    @mohd.irfanlohar4544 Před 2 lety +1

    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

  • @sahilpatil9957
    @sahilpatil9957 Před rokem +1

    very nice video, helped me understand concept of inheritance very easily

  • @prasadprashantb.4001
    @prasadprashantb.4001 Před 2 lety +2

    Harry bhai bahut achhe video banate ho ❤🙌 keep it up...! For us.. 🤟ty bhai❤❤

  • @ni1836
    @ni1836 Před 3 lety +1

    THANKYOUUU SO MUCHH!!!! ✨✨

  • @shivanshgoyal310
    @shivanshgoyal310 Před 3 lety +1

    I have seen all your videos till here.. They are the best 🔥🔥🔥🥰🥰🥰💖💖

  • @kaushikchauhan2452
    @kaushikchauhan2452 Před 2 lety +1

    easy understanding of concepts of oops and C++

  • @manish_jangir16_______________

    Yes , we can change Data1 value by the creating Member function.

  • @jinsishahcs7889
    @jinsishahcs7889 Před 2 lety +1

    you are amazing harry bhai! keep this up! :)

  • @dsaipranav
    @dsaipranav Před 4 lety

    Your videos are very helpful for understanding C++.
    Thank you Bro.

  • @ManpreetSingh-nm2qd
    @ManpreetSingh-nm2qd Před 4 lety +2

    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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @engineerbhai7642
    @engineerbhai7642 Před 4 lety

    Harry is genius and excellent coder in you tube.

  • @AshutoshKumar-fu6qe
    @AshutoshKumar-fu6qe Před 3 lety +6

    Oh man! What a like to dislike ratio! Nice! It's more than 2 hundred. Great job harry bhaiya!

  • @saishubhamray9729
    @saishubhamray9729 Před 3 lety

    Yes I am Learning C++ very fast than never before just because of you

  • @saumitramuley5170
    @saumitramuley5170 Před 2 lety +1

    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

  • @DineshSingh-hx5kw
    @DineshSingh-hx5kw Před 2 lety

    Very helpful content...Keep uploading such type of content.....Thank You

  • @prakharkothari4351
    @prakharkothari4351 Před 2 lety

    bahut aache se samjh aarahi hai

  • @sauravmandal5
    @sauravmandal5 Před 2 lety

    Bhaiya loving your lectures , Thankyou for all this to us .

  • @strein6502
    @strein6502 Před 3 lety +1

    Thanks Harry vai for this classs

  • @manavroy7293
    @manavroy7293 Před 2 lety

    Thanks, You're an amazing programing teacher ,I love you❤️

  • @barberrionking453
    @barberrionking453 Před 3 lety +1

    Thank you Thank-you so much sir ❤️❤️❤️

  • @ashutoshgiri2974
    @ashutoshgiri2974 Před 2 lety

    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

  • @vedhikasaraswat
    @vedhikasaraswat Před rokem +1

    thank you so much harry !!!

  • @skmdimtehaz4185
    @skmdimtehaz4185 Před 2 lety

    Bhai thank You yar .... Itna help hota h apke channel se vdo dekh k 🥰🥰🥰

  • @yuktisanghavi4645
    @yuktisanghavi4645 Před 3 lety +2

    Best tutorials!

  • @techtrap4670
    @techtrap4670 Před 2 lety

    Harry bhai your teaching techniques are just awesome...maza aa gaya..

  • @Parvesh_Bansal
    @Parvesh_Bansal Před 2 lety +1

    awesome video harry bhai

  • @Pooh__7__
    @Pooh__7__ Před 3 lety

    we can set data one value by defining a method publicly in base class, we can access that in the main( ) by calling it

  • @ishikajain7075
    @ishikajain7075 Před 3 lety +1

    👍👍👍👍👍you are a very good teacher👍

  • @royfamily9273
    @royfamily9273 Před 2 lety

    Thanks Harry Bhaiya

  • @Aditya.Pathak16
    @Aditya.Pathak16 Před 4 lety

    Fabulous bhaiya..
    Waiting for next one

  • @ritikroshan9681
    @ritikroshan9681 Před 3 lety +2

    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.

  • @abhijitsurve6704
    @abhijitsurve6704 Před 2 lety

    Harry bhai iss lecture mai jo aapne smjhaya hai na ooo bahut jyada OP hai.Thank you sir....

  • @kirtik3859
    @kirtik3859 Před 2 lety

    understandable lecture for coding.
    thanku

  • @nkbanerjee2549
    @nkbanerjee2549 Před 2 lety

    I really enjoyed it very much Harry bhai ❣️❣️❣️💞💞💞

  • @dragonwarrior7246
    @dragonwarrior7246 Před rokem +1

    Thank you, thank you, thank you ❤️❤️🥰

  • @anshpandey6015
    @anshpandey6015 Před rokem

    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🙏

  • @priyanshkashyap2993
    @priyanshkashyap2993 Před 2 lety

    You make it easy ..👍

  • @rishabnayal4430
    @rishabnayal4430 Před 2 lety +1

    your teaching is so good and congrats for 2M ❤ ❤

  • @ratnakantahanse2661
    @ratnakantahanse2661 Před 4 lety +1

    Nice sir...... I love the course...

  • @sandipwakade1100
    @sandipwakade1100 Před 3 lety

    Very helpful harry bhai👌🏾👌🏾👌🏾👌🏾

  • @hamzaabbasi3530
    @hamzaabbasi3530 Před rokem

    Bht axha smja rha bhaii ap thnxxx

  • @MuhammadUsman-bm7qb
    @MuhammadUsman-bm7qb Před 2 lety

    Very helpful tutorial Harry Bhai.

  • @_TheInquistive
    @_TheInquistive Před 6 měsíci

    Thankyou bhaiya going on the way with your videos

  • @abhishekrawat8074
    @abhishekrawat8074 Před rokem

    Yes, we can set data1 indirectly with the help of methods or even constructors

  • @mohammadibrahim6778
    @mohammadibrahim6778 Před 2 lety

    Excellent!

  • @mohitacharya2570
    @mohitacharya2570 Před 3 lety +2

    brother 999K .. 1M hone wale hai. congrats harry bhai

  • @codewithharryfanchannel559

    You are best coder in you tube.

  • @amitbehera9850
    @amitbehera9850 Před 4 lety +1

    Hari bhai Dil se ❤️❤️❤️

  • @chaitanya6521
    @chaitanya6521 Před 4 lety +7

    I'm so comfortable in your teaching style so please java ka full course le aao

  • @yogeshjangid3696
    @yogeshjangid3696 Před 3 lety

    You are awesom harry bhai

  • @yogeshjangid3696
    @yogeshjangid3696 Před 3 lety +1

    Thanks for free knowledge

  • @siddharthsable7762
    @siddharthsable7762 Před 3 lety +1

    Thanks HarryBhai!

  • @AhmedRaza-ty7zq
    @AhmedRaza-ty7zq Před 6 měsíci +1

    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.

  • @tarunsahuje9043
    @tarunsahuje9043 Před rokem

    Harry bhai bhut he completed videos ha...

  • @mohammedwaseem8599
    @mohammedwaseem8599 Před 3 lety +1

    Super fantastic video

  • @parth8746
    @parth8746 Před 3 lety

    Awesome explaining sir ji

  • @rohit_vlog2001
    @rohit_vlog2001 Před 2 lety +1

    Very helpful

  • @shubhambhosale2723
    @shubhambhosale2723 Před 3 lety +1

    Thank you 😊

  • @abhishekpandit6287
    @abhishekpandit6287 Před 3 lety

    bhai bhot bdiya samjhaya h

  • @GAMINGHUNT04
    @GAMINGHUNT04 Před 3 lety

    samaj aa gya bro.

  • @vikustorm3411
    @vikustorm3411 Před rokem +1

    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.

  • @jaat_gulyana_wala
    @jaat_gulyana_wala Před 3 lety

    Very very very excellent and great
    Job sirrrrrr

  • @dalvinder_kaur
    @dalvinder_kaur Před 2 lety

    Thankyou so much ❤️

  • @mohammedkaifmirza7585
    @mohammedkaifmirza7585 Před 2 lety

    yes harry bhai, sab samjh me aaraha hai jo aap padhaa rahe ho

  • @AhmedRaza-ty7zq
    @AhmedRaza-ty7zq Před 6 měsíci +1

    Awesome video😎😎👍👍

  • @yashrajnegi10
    @yashrajnegi10 Před 3 lety +1

    21:30 very helpful harry bhai❤

  • @mayanksoni1600
    @mayanksoni1600 Před rokem

    Videos are helpful Bhai !!

  • @DHEERAJKUMAR-uu2ir
    @DHEERAJKUMAR-uu2ir Před 2 lety

    it is very helpful for everybody

  • @D-Coder440
    @D-Coder440 Před rokem

    Thank you Harry Bro ❤️❤️

  • @ammarronaldo2006
    @ammarronaldo2006 Před 3 lety

    Thank you Harry bhai

  • @opmemes2392
    @opmemes2392 Před 3 lety

    Bahot achha

  • @sagarikasardesai6708
    @sagarikasardesai6708 Před 2 lety

    *_AMZING COURSE_*