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

Поделиться
HTML-код
  • Опубликовано: 6 сен 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 RUclips. 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 🙏

  • @mohamedsufian8360
    @mohamedsufian8360 3 года назад +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 ?

  • @MayankSingh0303
    @MayankSingh0303 5 лет назад +6

    best videos for c++....

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад

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

  • @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♥️♥️♥️

  • @hasannaqvi5539
    @hasannaqvi5539 4 года назад +3

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

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

  • @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?

  • @GbbxK
    @GbbxK 3 года назад

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

  • @user-rz9jh1pp8k
    @user-rz9jh1pp8k 4 года назад

    You definitely save my life. Thanks for clear explanation.

  • @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 😇

  • @awaisrana8239
    @awaisrana8239 3 года назад

    Your tutorials very helpful for me
    Thank you sir❤

  • @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?

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

  • @aman8778
    @aman8778 2 года назад

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

  • @ramzidanoun2441
    @ramzidanoun2441 2 года назад

    Best c++ tutorial

  • @tapasvig5152
    @tapasvig5152 Год назад

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

  • @jamesnash9675
    @jamesnash9675 2 года назад

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

  • @dinesh.p8642
    @dinesh.p8642 4 года назад +3

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

    • @SimpleSnippets
      @SimpleSnippets  4 года назад

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

    • @dinesh.p8642
      @dinesh.p8642 4 года назад

      @@SimpleSnippets thank you..👍

  • @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??

  • @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();
      }

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

  • @tabijohn7992
    @tabijohn7992 6 лет назад +2

    awesome. me loving it

    • @SimpleSnippets
      @SimpleSnippets  6 лет назад

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

  • @1secondfun794
    @1secondfun794 4 года назад +1

    Thanks

  • @abhimanyu6534
    @abhimanyu6534 3 года назад +1

    Plz make more and more videosss

  • @zhalokrahman6654
    @zhalokrahman6654 5 лет назад

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

  • @khandakaralif8180
    @khandakaralif8180 4 года назад

    you are a legend bro
    #respect

  • @abhimanyu6534
    @abhimanyu6534 3 года назад +1

    Bhaiyu osm

  • @adityachaudhari8386
    @adityachaudhari8386 3 года назад +1

    thank you bro .

  • @ashir6979
    @ashir6979 3 года назад

    BEST TUTORIAL

  • @Aman-gw7ro
    @Aman-gw7ro 4 года назад +1

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

  • @mshingote
    @mshingote 5 лет назад +1

    Can you please explain private pure virtual function?

    • @SimpleSnippets
      @SimpleSnippets  5 лет назад +1

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

    • @mshingote
      @mshingote 5 лет назад

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

  • @dattabhabal421
    @dattabhabal421 5 лет назад

    what is virtual destructor

  • @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🥺🥺😖😖

  • @noor_edits_
    @noor_edits_ 7 месяцев назад

    ❤❤❤

  • @zhalokrahman6654
    @zhalokrahman6654 5 лет назад

    why do we need the pure virtual funtions?

    • @Arjunsiva
      @Arjunsiva 5 лет назад

      Thats a wonderful question!!!!

  • @nagababuveeranki5429
    @nagababuveeranki5429 3 года назад +1

    Jai geeksforgeeks

  • @blackwarrior6015
    @blackwarrior6015 3 года назад

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

  • @jehreela_JAAT
    @jehreela_JAAT 4 года назад +1

    🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸

  • @revealnexon7701
    @revealnexon7701 3 года назад

    Bhai tero mistake vo