Virtual Functions & Abstract Classes in C++ | C++ Programming Tutorials
Vložit
- čas přidán 27. 08. 2024
- Support Simple Snippets by Donations -
Google Pay UPI ID - tanmaysakpal11@okicici
PayPal - paypal.me/tanmaysakpal11
--------------------------------------------------------------------------------------------- In this video tutorial we will study and understand the concept of Virtual Functions and Abstract Classes and we will also see 2 practical examples of Virtual Functions.
Virtual Function in C++ - A virtual function is a member function which is declared within base class and is re-defined (Overridden) by derived class.
When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class’s version of the function.
1) Virtual functions ensure that the correct function is called for an 2) object, regardless of the type of reference (or pointer) used for function call.
3) They are mainly used to achieve Runtime polymorphism
4) Functions are declared with a virtual keyword in base class.
5) The resolving of function call is done at Run-time.
Pure Virtual Functions & Abstract Class in C++ - Sometimes implementation of all function cannot be provided in a base class because we don’t know the implementation. Such a class is called abstract class.
A pure virtual function (or abstract function) in C++ is a virtual function for which we don’t have implementation, we only declare it. A pure virtual function is declared by assigning 0 in declaration.
Some important facts -
1) A class is abstract if it has at least one pure virtual function.
2) We can have pointers and references of abstract class type.
3) If we do not override the pure virtual function in derived class, then derived class also becomes abstract class.
4) Abstract classes cannot be instantiated.
Download Dev C++ IDE : sourceforge.ne....
Download C++ Android App : play.google.co...
Simple Snippets Official Website -
simplesnippets...
Simple Snippets on Facebook-
/ simplesnippets
Simple Snippets on Instagram-
/ simplesnipp. .
Simple Snippets Google Plus Page-
plus.google.co...
Simple Snippets email ID-
simplesnippetsinfo@gmail.com
For Classroom Coaching in Mumbai for Programming & other IT/CS Subjects Checkout UpSkill Infotech - upskill.tech/
UpSkill is an Ed-Tech Company / Coaching Centre for Information Technology / Computer Science oriented courses and offer coacing for various Degree courses like BSc.IT, BSc.CS, BCA, MSc.IT, MSc.CS, MCA etc.
Contact via email /call / FB /Whatsapp for more info
email - upskillinfotech@gmail.com
We also Provide Certification courses like -
Android Development
Web Development
Java Developer Course
.NET Developer Course
Check us out on Social media platforms like Facebook, Instagram, Google etc
Facebook page - / upskillinfotech
Insta page - / upskill_infotech
Google Maps - goo.gl/maps/vj...
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 ✌
Fun Fact :- You don't dare to increase playback speed.
😂😂😂😂😂😂😂 true that 😂😂😂😂😂
well, i do XD
Its already increased to 1.5x so i wont
Yea right
I slowed it down to .50 and it was fine 😀
You videos saved my life! I have a test for which I fell asleep and didn’t prepare at all. Thank you! You are doing great :))
Thank you so much for such a wonderful response. Please do help me too. Share this video and channel with your friends and contacts and even they might go help from this ✌️😇
Man you are so good at teaching 😊
The way you drop links of your related lectures is so helpful.
Thanks a lot for saving my semester ❤️
The way you have explained all the videos on C++ concepts is just awesome. Thank you so much.
Most welcome ya 😊 this was a really motivating comment ✌️ please do share the video with your friends ✌️ that's the biggest help & support 😁
I don't understand how can someone dislike his videos I mean he is so good at explaining and he's better than any of the college teachers! Anyways thankyouuuu so much....
Thank you 😊 means a lot to me 🙌
Perfect explanation no bs straight to the point and also shows how it is useful, thanks!
what are different type of virtual functions
@@yuvrajsinghbajwa8039 pure virtual function and simply virtual functions
best video lectures ever seen by mean.
It is the only channel from which i can understand c++ !!
Thank you very much.good work bro!!
Most welcome buddy. Glad to hear this from you. please do share this videos and our channel with your friends too bro, thats the biggest help and support 😇
Tomorrow is my exam and Today I am here for Virtual function.
And my this concept is clear.
Thanks @SimpleSnippets
Great work, You have simplified what others complicate most of the time.
I'm glad I could make it easy. That's the biggest purpose of my channel 😊✌️
Bhai maza aa gaya! Kya samjhaya hai. Mere University ke teacher se to 100times bawal!!!
Hahahaha thank you Gaurav bhaai. Bohot acha laga ye comment padhke. please share kar do ye channel aapke dosto ke sath. Bohot help hojayegi!
Superb explanation !! it cleared my concept in just 15 mins.. excellent video man ..keep it up bro !!! you will go too far ..all the best
Thank you so much Bhushan 😊 super happy to hear this from you. I would request you to please share the video with your friends too ✌️😊 that'll be best 😊
I am a intern in a product company and this video really helped me. Osm explenation!
2 example is very good example to understand the concept of abstract and virtual function
Last second Peace was very funny LOL
😅😂
Your OOP lecture series is a gem
Damn good 💯. You sound so confident from the start I was like yaa gotchaa. Gotchaa. Finally understood. There was no space for doubt. Thanks man.subscribed.✨
You are videos are life saving one day before exam ☺️ thx a lot dude
i am amazed at your teaching ability
you got quality in you videos, beautifully explained!! to the point!
I liked your way of method of teaching😊with good quality of sound...
Just love your explanation man !
Thank you bro 😊
God of c++ lecture 🙌
Excellent explanation Tanmay. Thanks a lot!!
you don't have to create Animal class pointer because you can directly pass the Derived class object to the function with reference operator
function1(&catObj);
HEY IM IN 3RD SEMESETER RN AND I FOUND ALL THE LECTURES ON CZcams VERY LONG AND NOT WORHTY BUT YOUR LECTURES ARE TO THE POINT AND SHORT AND COVER EVERYTHING PLEASE TEACH DSA TOO.
DSA playlist is already on the channel.
Greatly Explained. Thanks for sharing knowledge.
very good explanation
sir , you teach in a so most excellent way
Thank you very much buddy. Happy to see your positive feedback. Please do share the videos with your friends too 😇
ok sir please make a video how to add graphics in dev c++ also thanks sir
Okay sure I'll try to cover that as well 😇✌️
@@SimpleSnippets i year gone and you haven't
I guess i have come here late to appreciate you. Amazing work man.
Late is better than never Samarth. Thank you so much for such wonderful appreciation. Please do subscribe to our channel and definitely share it with your friends too 😇
please add a tutorial on virtual destructors as well as early as possible sir I have exams this weekend...I have watched all YOUR videos tis they helped me a lot get out of all the problems I had with this language. Tanmay sir it would be a great favor
Sir, at 1:32, function overriding can not be achieved without virtual function!!!
Excellent Explanation. Use of Virtual function rel time example.. Awesome
Glad you liked it
what are different type of virtual functions?
Brilliant tutorial!
thank you so much sir!
Clever! thankyou very much. Great example!
Thank you so much buddy, Glad to hear this from you. Please do share the videos with your friends too bro 😇
The way of explaining is vary good ,neatly explained but need to be little slow the current video explanation is vary fast
Thanks Rashmi & yes I will remember maintaining a slower speed in future.
Just slow down the speed of the video from options
here to revise again :)
If you have to create the Object of derived class anyway then why not call the derived class function directly instead of calling passing it to the Base class pointer. Hoping you will help me to understand that by not giving bookish defination
Thanks for the explanation 👍
ur the best
plz tell at 13:55 why do we make one extra func...we can do it without it also naa???
you are the best.........masum
Thanks.
Excellent video man.
Thank you so much for the positive comment buddy. Do share the video with your friends and contacts 😇
Why to use Virtual function, when I can even run my code without using the virtual function??
much needed for that tutorials
love from pakistan
i have this problem where we need to call both virtual and derived function at the same time, and i can't understand how to do it
Thanks for sharing amazing content..!
I have few queries hope I'll get response 👇:
@1:31 Can you please tell that why specifically we need virtual function when override is possible using function overriding?
because for function overloading, you either need different no. of parameters or different data type of parameters, so technically you will need to write use char for cat food and string for dog food, as an example and also you'll have to write the two functions seperately, which is not really feasible and it also wastes more memory bcuz it is two seperate functions. in virtual function he wrote only one function func1 and printed both dog and cat food with it, basically virtual functions can be used to sort of overload when your two functions are having same parameters or same data types
You're amazing, thank you so much!
You're very welcome! It would mean a lot if you could please share our channel and videos with your friends too ✌
great bro nice 👍
Glad you liked it! Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇
really great, thanks.
Thanks buddy, glad to hear this. please do share the video with your friends too. Thats the biggest help and support 😇
Great video and explanations!
Glad you liked it!
Tanmay you rocks!
Thank you Kashif. Glad to hear this from you. Please share this video with your friends too 😇
@@SimpleSnippets yep! Sure!
Nice explination man
Glad you think so!
@@SimpleSnippets not my thinking bro its the fact
Thank you so much 😊 means a lot bro ✌️
oh my god you have no idea of how much I love you lol
greattt brother!!!!
The accent and speech speed is a pain in the ass and my ears bleed, but damn it's a very high quality explanation with that second example of cats and dogs. Well done 👏
I have doubt as I'm a beginner so don't mind me you made Saperate void function
but if we just directly points it like we did in first program something like this:
Animal *ptr;
Cat obj;
Ptr=&pbj;
Ptr->eat() ;
So it's gonna work same right????
Thanks alot
Most welcome. Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇
Without using the function1 we can print respective message for corresponding object
Great sir thanx a lot
Most welcome! Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇
Thank You SO Much Sir
There is no card or link in top right corner coming
. thanks❤️
please make a video how to add graphics library in dev c++
Hi teacher, Can I understand "Virual Function same Override" ?
Hello, I didnt understand your question properly but yeah virtual functions also enable us to perform function overriding.
Thank you teacher ^^ my question: Virtual function is override ?
+Huy võ lê yes virtual functions help us in function overriding and dynamic polymorphism. ✌️
Which programming language should I start right now. Please tell with consideration to Future. I am in class XII right now. After board exams, I want to learn programming.
+ABHISHEK VERMA complete c++ then Java. ✌️
Simple Snippets
thanks *tanmay* bhai
How can an assingment operator (=) is used for objects without using operator overloading?
Very helpful video
Glad it was helpful! Please support me by sharing the videos and our channel with your friends too. Thats the biggest help and support you can provide 😇
can u plz upload videos on all concepts of classes and objects @simplesnippets
Here is the full playlist of C++ Programming, you might find your topics here - czcams.com/video/AKNGgAXTark/video.html
If we write program for pure virtual function then it will also for abstract class or not? As we know pure virtual function is known as abstract class..
what are different type of virtual functions?
Hy sir, I can write the whole C++ program but when the time to access the values to call the implementation. I am gonna stuck. Please can you teach me about this?
Simple Snippets I wanna ask a question that can we make a function virtual in derived class as well or only in base class we can do it?
If the derived class has a child class inheriting from it then I think you can use virtual functions in that derived class. But I'm no expert in inheritance so please take this with a grain of salt.
There's not any tutorial on Composition :(
Encapsulation ke bareme batayiye sir
BTech electronics and communication technology k sem 3 mein oop ka exam hai kal. I will pass it because of this video
Great video !! very well explained. Kudos
Thank you! ✌
What is the difference between Visual C++ and Dev C++?
Like im using VC++ and its fun, i haven't tried Dev C++.
Sir you cannot answer for my question in the last video. Why we are using scope resolution
I will make shape area example by own ....😎😎😎
How you make it so simple and easy to understand yaar correct speed correct language.
Hats off to you👌👌👌👌
Thanks Neeraj 😊 super happy to keep hearing your amazing comments ✌️😊
🎉
Bro which software are u using for black board ?
It's called smoothdraw4. It's free and open source ✌️
superb :)
But without using virtual keyword alone would print out the value of generic class for me so could you explain what's the use of that standalone function?
what are different type of virtual functions
can u plz upload d overloading of binary operators using friend functions
please bro put all the video tutorial in sequence,,otherwise great job!!
Hey Aman, all the tutorials are pretty much in proper sequence only in the C++ programming playlist. Checkout this playlist in the playlists section of the channel ✌️😊
6:12 Why you are not using acess specifiers in Myderived ?
he did....
public MyBase
Why did you make baseptr as a pointer?
EDIT: i notice later that you say it allows you to make it point to any object of MyBase class. You then utilize this later when you make function1 so that it can call cat or dog. I guess that is why...
🔥🔥
Sir thordsa slow smjhaeye 😐
Sorry for the fast speed ✌️
most people watch at 1.5x speed xD
hii bro , i am kuldeep ,
IN THIS video tut. i don't understand program that you made ..
Explanation!👍🤝
gud bro
+Technical Riwash thank you buddy. And sure will try to make videos on Python but currently already have a lot of tutorial requests so will first try to finish those ✌️
bro can u explain advanced c++ as well?
good
Thank you :-) Please share this with your friends and contacts too ✌ That will be the biggest help and support for our channel 😇
u did not tell about pure virtual
sir you slide pani halnuna note ko lagi
9:02