Pure Virtual Functions in C++ | C++ Programming tutorials for Beginners

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 69

  • @SimpleSnippets
    @SimpleSnippets  5 років тому +6

    Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

  • @usmclongrangebrainsurgeon
    @usmclongrangebrainsurgeon 6 років тому +34

    The BEST C++ tutorials on UA-cam. Excellent thank you

    • @SimpleSnippets
      @SimpleSnippets  6 років тому +1

      Wow thank you so much for such an amazing review. Definitely the best positive response as well ❤️
      Please do share the videos with your friends and contacts buddy. It'll be of great help 😇

  • @rengokuhasira6069
    @rengokuhasira6069 4 роки тому +10

    If you have less time and exams are near i really recommend your channel for quick knowledge awesome man you know how to make people job easy

    • @SimpleSnippets
      @SimpleSnippets  4 роки тому +2

      Thank you very much Mohan, really happy to see such support from you. And yes thank you for sharing this video and channel and spreading the knowledge 🙏

  • @sharmass3756
    @sharmass3756 4 роки тому +4

    wow man really great i watched all ur videos u saved me for tommorows exam great

    • @SimpleSnippets
      @SimpleSnippets  4 роки тому +1

      Thats great to hear buddy, Please do subscribe and share our channel with your friends too! Thats the biggest help and support 😇

    • @sharmass3756
      @sharmass3756 4 роки тому +1

      @@SimpleSnippets yes sir I shared your videos to my friends and subscribed to ur channel also♥️♥️♥️

  • @MayankSingh0303
    @MayankSingh0303 6 років тому +6

    best videos for c++....

    • @SimpleSnippets
      @SimpleSnippets  6 років тому

      Thanks Mayank 😇❤️ really happy to hear this from you. Please do share the videos with your friends too 🙏

  • @ramzidanoun2441
    @ramzidanoun2441 2 роки тому

    Best c++ tutorial

  • @mohamedsufian8360
    @mohamedsufian8360 4 роки тому +5

    I know how to use virtual function,pure virtual function but I can't understand where to use it because instead of using them we can directly use normal member function override then why we use them ?

  • @GowthamVarmaSrinivasan
    @GowthamVarmaSrinivasan 2 роки тому

    Please clarify:
    From the basics we know that we cannot have a pointer or reference without an object bound to it. ( Strictly speaking we can have a nullptr, we are talking about class objects here)
    Now, we cannot have objects of abstract class type, and that is true by theory.
    So how can we have pointers and references of abstract class type? (2nd fact you mention at 1:40).
    Thanks

  • @ដង្កូវសៀវភៅ

    You definitely save my life. Thanks for clear explanation.

  • @GbbxK
    @GbbxK 3 роки тому

    Thanks this video and the video on virtual functions helped a lot!

  • @Sabari-gd3fw
    @Sabari-gd3fw Рік тому

    Thanks for explanation...could you please tell me..why we couldn't able to create an object for an abstract class?

  • @jamesnash9675
    @jamesnash9675 2 роки тому

    you are the best...........masum

  • @awaisrana8239
    @awaisrana8239 3 роки тому

    Your tutorials very helpful for me
    Thank you sir❤

  • @hasannaqvi5539
    @hasannaqvi5539 4 роки тому +3

    Sir, you mean we don't have to calculate the area by calling through a base pointer? Kindly update me

  • @adityasarin39
    @adityasarin39 4 роки тому +2

    Keep it up, man! Great explanation

    • @SimpleSnippets
      @SimpleSnippets  4 роки тому

      Thats really great to know buddy🙏 Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇

  • @1secondfun794
    @1secondfun794 4 роки тому +1

    Thanks

  • @dinesh.p8642
    @dinesh.p8642 5 років тому +3

    Tanmay bro,, Can u make the reactjs tutorials...for us..

    • @SimpleSnippets
      @SimpleSnippets  5 років тому

      I'm not really acquainted with react js but maybe I'll collaborate with some expert in future 🤘😊

    • @dinesh.p8642
      @dinesh.p8642 5 років тому

      @@SimpleSnippets thank you..👍

  • @adityachaudhari8386
    @adityachaudhari8386 3 роки тому +1

    thank you bro .

  • @khandakaralif8180
    @khandakaralif8180 4 роки тому

    you are a legend bro
    #respect

  • @abhimanyu6534
    @abhimanyu6534 3 роки тому +1

    Plz make more and more videosss

  • @fleek4338
    @fleek4338 3 роки тому +1

    I still have the same question as before!! Why to use virtual function, when I can run my code even without using virtual function??

    • @fondfrequencies9409
      @fondfrequencies9409 3 роки тому

      Yeah me too
      I think if it's mandatory to use pointers in the question,we have to go for virtual functions orelse we can just override....

  • @tabijohn7992
    @tabijohn7992 6 років тому +2

    awesome. me loving it

    • @SimpleSnippets
      @SimpleSnippets  6 років тому

      +Tabi John thank you for the support buddy 😇✌️ this means a lot 😇

  • @abhimanyu6534
    @abhimanyu6534 3 роки тому +1

    Bhaiyu osm

  • @ashir6979
    @ashir6979 3 роки тому

    BEST TUTORIAL

  • @aman8778
    @aman8778 2 роки тому

    Sir thank you for this video...but sir how to be so frequent in speaking English just like you

  • @Aman-gw7ro
    @Aman-gw7ro 4 роки тому +1

    Thank you so much bro .... really helpful !!!

  • @SonSon-rq5dj
    @SonSon-rq5dj 3 роки тому +2

    I did the exact code in my IDE, however, I removed the pure virtual function and it still works fine when creating and calling getArea() methods for the circle and rectangle class. May I know what is a pure virtual function used for?

  • @tapasvig5152
    @tapasvig5152 2 роки тому

    Can u give the program for pure virtual function in c++ .Give the program shorter

  • @noor_edits_
    @noor_edits_ 9 місяців тому

    ❤❤❤

  • @dattabhabal421
    @dattabhabal421 5 років тому +2

    what is the use of pure virtual function, I mean if we do not have to implement the function then why should we write that function in our class

    • @SimpleSnippets
      @SimpleSnippets  5 років тому

      Let's say you create parent class as animal and create sound() method in it. Then you create 2 child classes of cat and dog and inside that you want individual sound methods for each class. In cat the sound () method should print - cats meow
      and for dogs class the sound () method should say - dogs bark
      Now if you come to the parent animal class unless you know what type of animal it is, you cannot have anything inside the sound () method right? Because it won't make sense since we do not know what animal it is. So hence we use pure virtual function when we don't know what exactly the parent class method/function is going to do.

    • @dattabhabal421
      @dattabhabal421 5 років тому

      @@SimpleSnippets ok got it Thanks for quick response
      Hope u rply me for my other doubt also which i have commented on other video as well asap
      Once again thankee buddy

    • @TheAdityaVerma
      @TheAdityaVerma 5 років тому +1

      @@SimpleSnippets why dont just dont create the method sound in base class in the first place?!

    • @SimpleSnippets
      @SimpleSnippets  5 років тому

      That's exactly what I explained here buddy. Until an unless you don't know what animal it is, how can you create the sound method in the base class? Cause sound method of one animal with be different to that of the other 🤟

    • @TheAdityaVerma
      @TheAdityaVerma 5 років тому +1

      your awesome!!
      please make more videos on the topics like this pointer, encapsulation and abstraction.
      wat your doing is really precious

  • @zhalokrahman6654
    @zhalokrahman6654 5 років тому

    in pure virtual func cant we just give input in the first brac likes getarea(int a)???

  • @dattabhabal421
    @dattabhabal421 5 років тому

    what is virtual destructor

  • @mshingote
    @mshingote 6 років тому +1

    Can you please explain private pure virtual function?

    • @SimpleSnippets
      @SimpleSnippets  6 років тому +1

      I suppose that's what I did in this video 😅

    • @mshingote
      @mshingote 6 років тому

      @@SimpleSnippets I think you have explained public pure virtual function. Can you explain why and when we need 'private' pure virtual function?

    • @dattabhabal421
      @dattabhabal421 5 років тому

      @@mshingote why we need to declare any function in private as we know that anything declare in the private cannot be inherited

  • @shreedhoni4522
    @shreedhoni4522 2 роки тому

    In derived class you used public again this is the first you using public in derived class
    In previous videos you used public access specifier only in base classes not it derived classes
    When I didn't use public access specifier in derived class it showed me an error and it is private
    Can you explain why??

  • @nagababuveeranki5429
    @nagababuveeranki5429 3 роки тому +1

    Jai geeksforgeeks

  • @downeykids
    @downeykids 5 років тому +2

    This is not a good example of a pure virtual function. In this scenario you don't need a class shape to make the main function work. You need to use pointers to show a good example of a pure virtual function.

    • @mohansivadhas
      @mohansivadhas 4 роки тому +1

      yaa thats what i was searching

    • @liontalha7383
      @liontalha7383 4 роки тому +3

      You can do it by yourself using pointer
      like this
      int main()
      {
      shape *ptr;
      circle c1;
      ptr=&c1;
      ptr->getarea();
      rectangle r1;
      ptr=&r1;
      ptr->getarea();
      }

  • @blackwarrior6015
    @blackwarrior6015 3 роки тому

    Ух.. индусы.. чтобы я без вас делал?

  • @jehreela_JAAT
    @jehreela_JAAT 4 роки тому +1

    🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸

  • @zhalokrahman6654
    @zhalokrahman6654 5 років тому

    why do we need the pure virtual funtions?

    • @Arjunsiva
      @Arjunsiva 5 років тому

      Thats a wonderful question!!!!

  • @patrickamstad5091
    @patrickamstad5091 5 років тому +5

    This tutorial is completly useless; you can delete the whole shape class and the programm would work exactly the same? So what is the point of using an example to explain a concept, where the concept isn't even used?
    For all the ones that are confused:
    - you cannot create an object of an abstract class BUT you can create a pointer of an abstract class
    - then considering his video of virtual functions (which was really good) you can acess all different getArea() functions with a single pointer type
    Hope that helps :)

    • @naeroforceofficial
      @naeroforceofficial 5 років тому +3

      This helped a lot! You can create a pointer of Shape type, then create Rectangle and Circle object and make the Shape pointer point to one of those objects, for example circleObj, and then by using ptr->getArea the area of the circle will be printed! Then if we need the area of the rectangle the Shape pointer can then point to the rectangle and by using ptr->getArea the area of the rectangle will be printed! Amazing!

    • @learncseasily3385
      @learncseasily3385 2 роки тому

      Bro if we create pointer of base class and point to derived objects then also we are creating derived objects right when we can simply call the function through derived objects itself then why to create a base pointer and if we dont create pointer and do the same as shown in the video then also it is confusing me like why to use pure virtual function it is just simply overriding the function itself i didnt seen the use of pure virtual function in this example because if we remove the pure virtual function also then also it works fine.. plz help me guys🥺🥺😖😖

  • @revealnexon7701
    @revealnexon7701 3 роки тому

    Bhai tero mistake vo