Pure Virtual Function In C++

Sdílet
Vložit
  • čas přidán 29. 08. 2024
  • JOIN ME
    -----
    CZcams 🎬 / @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
    Pure Virtual Function
    SYNTAX: virtual returntype functionname(parameters...) = 0;
    NOTES:
    0. If some class can have only signature of function but not the body then we use pure virtual functions.
    1. Sometimes in Base class we know the function name but not the definition of the function, so we want Derived classes to provide the definition of the function.
    2. We can actually give body of pure virtual function.
    3. If you have pure virtual function in your class, it means that class is an Abstract class and you can't create an object of that class. (But pointers and Reference can be created)
    USE CASE:
    1. Used to create abstract classes, which helps in creating interfaces (APIs)
    #cpp #virtualfunction #programming #coding #softwareengineering

Komentáře • 88

  • @pinakipb2
    @pinakipb2 Před 3 lety +15

    Your CPP series is just a lifesaver!

  • @mdatifbinkarim3877
    @mdatifbinkarim3877 Před 3 lety +6

    One of the best explanations I have found here regarding intimidating C++. Learned a lot from your content. My best wishes to you.

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

    Even a pure virtual function can have definition, I was not knowing this. Thank you sir. Your videos are just amazing. Keep on posting videos related to C++ Sir.

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

    I didn't know that we can define pure virtual function in base class...Thank you

  • @ranjanrajesh08
    @ranjanrajesh08 Před rokem +1

    Amazing…I didn’t know we can give body for pure virtual fn…your tutorials are amazing n there is always something new to learn from your videos even after knowing the concepts🙏🏻

  • @sunny0287
    @sunny0287 Před rokem

    More likes and subscriber you should have... very clear and crisp explanation at right pace...

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

    I didn't knew it..
    Thank you so much for this channel and knowledge sharing.
    More power to you ✌

  • @srinivasbusani9450
    @srinivasbusani9450 Před 2 lety

    Most underrated channel brother for the kind of explanation you give

  • @prashantchavan2673
    @prashantchavan2673 Před 2 lety

    9:43 you absolutely deserves "like" for this and yes you got it!

  • @bittupandey6645
    @bittupandey6645 Před 3 lety

    gyan ka bhandar you are best !!

  • @pallavichaudhary6636
    @pallavichaudhary6636 Před 7 měsíci

    A pure virtual function can have definition, I was not knowing this. Thank you sir.

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

    After a long time 😁

  • @ChandraShekhar-by3cd
    @ChandraShekhar-by3cd Před 3 lety +3

    Thanks a lot for the new Year video. Its been quite long to see you man, How are you doing. HNY 2021. Learnt a lot form your video series. Please keep posting videos on System design, OOD Design as well as these are quite a market boom topic for the FANG! .Thanks

  • @yashaggarwal6760
    @yashaggarwal6760 Před 2 lety

    i didn't knew body of pure virtual function. thanks

  • @sandeepmaurya1694
    @sandeepmaurya1694 Před 3 lety

    much better then code with harry c++ tutorial vdo
    thnk you sir

  • @ahcenebelhadi955
    @ahcenebelhadi955 Před rokem

    i'll definitely support you on patreon !!

  • @sujeshlx
    @sujeshlx Před rokem

    Great information

  • @jayantsharma2669
    @jayantsharma2669 Před 3 lety

    Good to see you're back 😊

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

    The animls who eat( veg) only = herbivores,
    Who eat (non veg )= carnivores,
    Who eat both =omnivores.

  • @sauravnegi8858
    @sauravnegi8858 Před 2 měsíci

    Thanks brother

  • @rkrahul2291
    @rkrahul2291 Před 3 lety

    Thanks, Bro for Knowing us new things

  • @mba2ceo
    @mba2ceo Před 10 měsíci

    thank U very much !!! I will comment :)

  • @rakeshvarma9424
    @rakeshvarma9424 Před 7 měsíci

    This was new for me

  • @AnilKumar-xh6hw
    @AnilKumar-xh6hw Před 2 lety

    I loved this stuff...

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

    U r awsm really 🥰

  • @GARV_K_JAIN
    @GARV_K_JAIN Před 3 lety

    i didn't knew that.. thankss :)

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

    Can we have a series on Socket Programming ...?

  • @abhishekrai617
    @abhishekrai617 Před 3 lety

    Good One, Sir Why Reference is created of abstract Class while reference is just alias name ?

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

    Can you do a video on virtual table and vptrs

  • @ganeshjoshi1619
    @ganeshjoshi1619 Před 3 lety

    Hey Rupesh,
    Thanks for the video.
    Can you please make one video covering vtable and vptr topic only.
    Thanks
    More power to you ✌

  • @naveen307_4
    @naveen307_4 Před 3 lety

    Dear sir, concept of virtual functions holds same for virtual class also like vptr and vtable? Could you plz give us idea on virtual base class internal working like diamond problem?

  • @sirraStudios
    @sirraStudios Před rokem

    Sir please make a video on vptr and vtable

  • @ParvezKhanPK
    @ParvezKhanPK Před 3 lety

    After a long time. Welcome back.
    By the way your voice changed a bit heavy tone.

    • @CppNuts
      @CppNuts  Před 3 lety

      Thanks man..
      Sound would be an issue, i am not using my own setup, it's my brother's.

    • @ParvezKhanPK
      @ParvezKhanPK Před 3 lety

      @@CppNuts to answer your question: yes, I always thought that pure virtual function doesn't have a body lol. I was wrong.

  • @curious_haldar
    @curious_haldar Před 3 lety

    Nicely explained!

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

    If we define the definition to pure virtual function, it means that definition behaves as default and changed in child classes if required ??

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

      But default means it should be able to be called if Derived class is not providing that definition but that's not the case here. Actually Derived class have to provide the definition otherwise we can't create the instance of Derived class. Hope you got it!!
      Let me know if you need more help..

  • @kittuthegreat28
    @kittuthegreat28 Před 7 měsíci

    any video you have for vtble and vptr ?

  • @ranjanrajesh08
    @ranjanrajesh08 Před rokem

    But vptr n virtual table concepts are not covered in this series

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

    why u have not uploaded more videos on virtual function

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

      Actually i had prepared to shoot and then somehow i lost my notes, then this is postponed, i will plan quickly, as so many people are demanding this.

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

    bhai content 1 number hota h tumhara bus advertisment thodi kam kar lo focus kharab ho jata h

    • @CppNuts
      @CppNuts  Před 3 lety

      Ok..
      I will take care next time.
      Thanks man..

  • @mr.habibivlogs9887
    @mr.habibivlogs9887 Před 2 lety

    How did you call Animal::move in derived class which is not static function.

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

    that snake is a snack (✿◠‿◠)

  • @vaibhav31
    @vaibhav31 Před 3 lety

    @CppNuts what do you prefer Joining your Pro on youtube or donating on your patreon??? .......... I will do whichever You want...

    • @CppNuts
      @CppNuts  Před 3 lety

      Hi @Vaibhav I would prefer patreon as its processing charges are less.
      Thanks for considering..

  • @LeelaseshuKumar
    @LeelaseshuKumar Před 3 lety

    Hey Rupesh , after long time . What happened any problems there. Thanks for uploading.

    • @CppNuts
      @CppNuts  Před 3 lety

      No issue, I am at hometown so delayed.
      Thanks for asking.

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

    🔥

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

    😳I was not knowing that

  • @nitinjain3866
    @nitinjain3866 Před 3 lety

    I am not able to find your video on virtual table and virtual pointer

    • @CppNuts
      @CppNuts  Před 3 lety

      It's because i have not given that yet.
      will push in few days.
      i got my setup back.(back to Banglore)

    • @nitinjain3866
      @nitinjain3866 Před 3 lety

      @@CppNuts Thanks, I will wait for the same :-)

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

    I knew

  • @nandigamshanmukanand1410

    I don't know that pure virtual function body can be created

  • @akhtrabadsaraikivlog5877

  • @pawanugale8149491331
    @pawanugale8149491331 Před 2 lety

    I didn't know that

  • @mohammadhosein6847
    @mohammadhosein6847 Před 3 lety

    that's how interfaces work in C++. I'm a java guy

  • @harry15396
    @harry15396 Před rokem

    Is no body gonna mention 'Snack'?

  • @pragyashrivastava4382
    @pragyashrivastava4382 Před 2 lety

    its snake not snack

  • @sabbulingineni
    @sabbulingineni Před 2 lety

    don't know thanks