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 ✌
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 😇
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 🙏
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 ?
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
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 😇
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?
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.
@@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
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 🤟
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??
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.
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(); }
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 :)
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!
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🥺🥺😖😖
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 ✌
The BEST C++ tutorials on UA-cam. Excellent thank you
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 😇
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
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 🙏
wow man really great i watched all ur videos u saved me for tommorows exam great
Thats great to hear buddy, Please do subscribe and share our channel with your friends too! Thats the biggest help and support 😇
@@SimpleSnippets yes sir I shared your videos to my friends and subscribed to ur channel also♥️♥️♥️
best videos for c++....
Thanks Mayank 😇❤️ really happy to hear this from you. Please do share the videos with your friends too 🙏
Best c++ tutorial
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 ?
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.
Happy to help!
Thanks this video and the video on virtual functions helped a lot!
Thanks for explanation...could you please tell me..why we couldn't able to create an object for an abstract class?
you are the best...........masum
Your tutorials very helpful for me
Thank you sir❤
Sir, you mean we don't have to calculate the area by calling through a base pointer? Kindly update me
Keep it up, man! Great explanation
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 😇
Thanks
Tanmay bro,, Can u make the reactjs tutorials...for us..
I'm not really acquainted with react js but maybe I'll collaborate with some expert in future 🤘😊
@@SimpleSnippets thank you..👍
thank you bro .
You're welcome!
you are a legend bro
#respect
Plz make more and more videosss
I still have the same question as before!! Why to use virtual function, when I can run my code even without using virtual function??
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....
awesome. me loving it
+Tabi John thank you for the support buddy 😇✌️ this means a lot 😇
Bhaiyu osm
BEST TUTORIAL
Sir thank you for this video...but sir how to be so frequent in speaking English just like you
Thank you so much bro .... really helpful !!!
Glad it helped
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?
Same doubt bro
Have u got the ans ?
Can u give the program for pure virtual function in c++ .Give the program shorter
❤❤❤
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
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.
@@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
@@SimpleSnippets why dont just dont create the method sound in base class in the first place?!
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 🤟
your awesome!!
please make more videos on the topics like this pointer, encapsulation and abstraction.
wat your doing is really precious
in pure virtual func cant we just give input in the first brac likes getarea(int a)???
what is virtual destructor
Can you please explain private pure virtual function?
I suppose that's what I did in this video 😅
@@SimpleSnippets I think you have explained public pure virtual function. Can you explain why and when we need 'private' pure virtual function?
@@mshingote why we need to declare any function in private as we know that anything declare in the private cannot be inherited
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??
Jai geeksforgeeks
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.
yaa thats what i was searching
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();
}
Ух.. индусы.. чтобы я без вас делал?
🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸🌸
why do we need the pure virtual funtions?
Thats a wonderful question!!!!
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 :)
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!
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🥺🥺😖😖
Bhai tero mistake vo