Virtual Constructors & Destructors explained in Easiest Way! Most confusing C++ Interview Question!
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
Ma'am do continue the series! You explain too well
Thanks Keerti for posting this video & explaining the concept of virtual destructor in runtime polymorphism. Keeping making such informative videos.
Please keep continue this series as it will help many in understanding these concepts in depth 🙂
waiting for more amazing videos like this :)
pls continue this series... its really helpful!!!
What a concept sir ji !!😊
Mam, please continue with this series and cover more topics like this.... it's really helpful
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?
Mam, please continue with this series and cover more topics like this.
For sure Shrey. Please do share the videos with your friends. Will mean a lot to me 🙏🙏😇😇
Explained so nicely
So nice mam. Very precisel
Thank You !!
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.
Nice series....keep making it
Thanks Aman. Many videos coming up! 😇😇
Thank you
where did u learn c++ and did u read book about cpp
Crystal Clear Explanation.......
Thank you Subhradeep! ❤️❤️
Great explanation 🔥
Thanks ❤️ So glad you like it😇
keerti,
are you planning for graph workshop similar to "recursion and dyn programming work shop" u did last week.
please do let me know
make a video on virtual copy constructor.
Thanksss
hello mam, please make videos for what should be a roadmap for leetcode as a beginner.
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.
Please make more videos you explain so well
please continue the series!
But mam code written is in JAVA language ,what to do it with cpp language??
@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.
I think I used this once, while design a graphics package.
Please continue this series..
Can anybody tell me why the constructor of derived class is being called implicitly
Mam would you be continuing with series !!!!!!???? You channel has been very useful
Yup. Many videos planned for this series! 😇😇
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.
yeah i have the same doubt
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
Please continue this series
Ma'am Please make a series of C++ from the basics.Please
We should thank you. And that "thank you" at last was too sweet to digest😅😅.
Please increase the frequency of vedio in this playlist
Some interviewer said the constructor can also be virtual and said he was pretty sure about it. 😮
🧐🧐❤
Hi how can I contact you
Can there any c++ course with doubt solving
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?
Only when base pointer pointing to cold object address
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..
Reply pls
@@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.
I think I've seen this video earlier. Nonetheless, very informative video!
Reuploaded it coz I missed something in the last one. Could you spot the difference? 🤭🤭
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! 😄
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 😇😇
@@KeertiPurswani thanks for the acknowledgement Keerti! I thought it was in the earlier video, without which there would be no destructors in first place.
Make more videos on cpp
Please didi, upload more videos
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
Why dont you try running the code and watch the video again?
This is the running code @@KeertiPurswani
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