Virtual Constructors & Destructors explained in Easiest Way! Most confusing C++ Interview Question!

Sdílet
Vložit
  • čas přidán 6. 05. 2021
  • This video covers a confusing concept of virtual Destructors and constructors but I hope that after watching this video, it will be super easy for you!
    Hope the video helps. Let me know!!
    For more content like this, please Subscribe to my channel - / keertipurswani
    LinkedIn - / keertipurswani
    Instagram - keerti.purs...
    #Interview #Preparation #Coding #Questions #growwithkeertipurswani

Komentáře • 65

  • @shaheenrafiq5974
    @shaheenrafiq5974 Před 3 lety +12

    Ma'am do continue the series! You explain too well

  • @shashankcool
    @shashankcool Před 2 lety

    Thanks Keerti for posting this video & explaining the concept of virtual destructor in runtime polymorphism. Keeping making such informative videos.

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

    Please keep continue this series as it will help many in understanding these concepts in depth 🙂

  • @nidhisethi3135
    @nidhisethi3135 Před 2 lety

    waiting for more amazing videos like this :)

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

    pls continue this series... its really helpful!!!

  • @aishavkhandelwal2600
    @aishavkhandelwal2600 Před 2 lety

    What a concept sir ji !!😊

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

    Mam, please continue with this series and cover more topics like this.... it's really helpful

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

    Very Helpful ma'am, could you please continue making this series?
    Could you please tell what are some more Questions like these, which are very crucial?

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

    Mam, please continue with this series and cover more topics like this.

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

      For sure Shrey. Please do share the videos with your friends. Will mean a lot to me 🙏🙏😇😇

  • @divyagoyal455
    @divyagoyal455 Před 2 lety

    Explained so nicely

  • @sivaramakrishna3568
    @sivaramakrishna3568 Před 2 lety

    So nice mam. Very precisel

  • @amitkumar-bm6cj
    @amitkumar-bm6cj Před 2 lety

    Thank You !!

  • @ajitpawar7558
    @ajitpawar7558 Před 8 měsíci

    Thank You Ma'am. I had my interview in evening and the last thing which I saw is your video. And surprisingly the interviewer asked me this exact same question.

  • @aman_sahu
    @aman_sahu Před 3 lety

    Nice series....keep making it

  • @tukaramgaikwad1793
    @tukaramgaikwad1793 Před 2 lety

    Thank you

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

    where did u learn c++ and did u read book about cpp

  • @sraynitjsr
    @sraynitjsr Před 3 lety

    Crystal Clear Explanation.......

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

    Great explanation 🔥

  • @hscroot123
    @hscroot123 Před rokem

    keerti,
    are you planning for graph workshop similar to "recursion and dyn programming work shop" u did last week.
    please do let me know

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

    make a video on virtual copy constructor.

  • @mohitmotwani9256
    @mohitmotwani9256 Před 3 lety

    Thanksss

  • @AmitKumar-hr3pc
    @AmitKumar-hr3pc Před 3 lety

    hello mam, please make videos for what should be a roadmap for leetcode as a beginner.

  • @elanchezian4452
    @elanchezian4452 Před 3 lety

    hi
    I am working now in a small company where I dont find any experience which would be good for my long term/future career.
    I recently started programming like logical questions and data structure questions. I am able to solve the basic problems and around most of the medium problems with more time to think that the basic problems.
    Some times what happens is some problems are taking so so much time to think, if I am lucky I will get the logic by my own or I dont.
    I have a question here. What should I do now if I dont get the solution? Whether I can see the solution or I should think and get the solution by my own only?
    What I do is if I dint get slution I may leave that question or keep on thinking on that solution and after some time I forget that I was doing this question and jump to other.
    Is it good to see the solution if I dint get the logic?
    Please give your suggestions.

  • @lazypalette6254
    @lazypalette6254 Před 2 lety

    Please make more videos you explain so well

  • @tomerlevi2640
    @tomerlevi2640 Před rokem

    please continue the series!

  • @UtkarshGupta-hp3nm
    @UtkarshGupta-hp3nm Před 3 lety

    But mam code written is in JAVA language ,what to do it with cpp language??

  • @aseemsameer7281
    @aseemsameer7281 Před 2 lety

    @Keerti When we don't use any destructor, the default ones are called. Do the default ones also give undefined behaviour? Also, what if we keep the virtual destructor private? Hoping for your comment.

  • @colinmaharaj
    @colinmaharaj Před 2 lety

    I think I used this once, while design a graphics package.

  • @sumedh_a_k
    @sumedh_a_k Před 2 lety

    Please continue this series..

  • @apoorvjain5030
    @apoorvjain5030 Před 2 lety

    Can anybody tell me why the constructor of derived class is being called implicitly

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

    Mam would you be continuing with series !!!!!!???? You channel has been very useful

    • @KeertiPurswani
      @KeertiPurswani  Před 3 lety

      Yup. Many videos planned for this series! 😇😇

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

    I'm still not convinced with the explanation of why can't we make the constructor as virtual because in the previous video you have make the raise salary function as virtual in that case also by your explanation how could Employee class create a object and point to vtable if its raise salary itself is used to point to the vtable.

  • @ponnlaksmi2903
    @ponnlaksmi2903 Před rokem

    Hi do u know any career development programs i am software engineer having experience of 8 years in CPP I want to improve my knowledge and move to some product based company can u tell me any options

  • @alluruvarma8764
    @alluruvarma8764 Před 2 lety

    Please continue this series

  • @flammingoo2480
    @flammingoo2480 Před 11 měsíci

    Ma'am Please make a series of C++ from the basics.Please

  • @anupamdubey5736
    @anupamdubey5736 Před 2 lety

    We should thank you. And that "thank you" at last was too sweet to digest😅😅.

  • @pawancemk
    @pawancemk Před 2 lety

    Please increase the frequency of vedio in this playlist

  • @art4eigen93
    @art4eigen93 Před 4 měsíci

    Some interviewer said the constructor can also be virtual and said he was pretty sure about it. 😮

  • @brigthon6467
    @brigthon6467 Před 3 lety

    🧐🧐❤

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

    Hi how can I contact you
    Can there any c++ course with doubt solving

  • @jaggis4914
    @jaggis4914 Před 3 lety

    So, as I understand, if you are going to sub-class/inherit from a given class, make it’s destructor virtual otherwise don’t. Am I right?

  • @simonrajamburose361
    @simonrajamburose361 Před 10 měsíci +1

    Mam, constructor is to allocate memory, via destructor is to destroy that memory
    My question is, mam pls explain the pgrm how destructor delete the memory of the object..
    Pls confusing..

    • @simonrajamburose361
      @simonrajamburose361 Před 9 měsíci

      Reply pls

    • @ItsMeIshir
      @ItsMeIshir Před 8 měsíci

      @@simonrajamburose361 when you call delete on any object or object goes out of scope - in this case, the execution reached destructor then,, the object's destructor gets called to clear the all the object related memory.

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

    I think I've seen this video earlier. Nonetheless, very informative video!

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

      Reuploaded it coz I missed something in the last one. Could you spot the difference? 🤭🤭

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

      I don't know I am right, there was no public keyword in the earlier video as far as I remember. Do correct me if I am wrong! 😄

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

      You are right! And I also missed mentioning the delete statement without which destructors wouldn't have been called.
      These were pretty important points. So, deleted that video.
      Good observation skills! Glad you are noticing the details 😇😇

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

      @@KeertiPurswani thanks for the acknowledgement Keerti! I thought it was in the earlier video, without which there would be no destructors in first place.

  • @bhushannalawade4120
    @bhushannalawade4120 Před 2 lety

    Make more videos on cpp

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

    Please didi, upload more videos

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

    totally wrong :
    without virtual :
    Base Constructor called
    Derived Constructor called
    Base Destructor called
    with virtual :
    Base Constructor called
    Derived Constructor called
    Derived Destructor called
    Base Destructor called

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

      Why dont you try running the code and watch the video again?

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

      This is the running code @@KeertiPurswani

  • @AdityaNakhare
    @AdityaNakhare Před 2 lety

    Your explanation regarding virtual destructor is correct. But regarding virtual constructor, syntactically it is not allowed, but there is a idiom which reflects the virtual constructor like scenario
    isocpp.org/wiki/faq/virtual-functions#virtual-ctors