+ 1
Suggestion regarding practicing OOPs
Hi community, I am currently learning oops in cpp but i am not able to grasp the concept completely due to lack of examples and real life use cases for comcept like multiple inheritence,virtual function etc. Could you suggest me some platform or git repository which could help me to grasp these concepts with examples...
3 Respuestas
+ 2
Here are two websites that can help you out.
https://www.geeksforgeeks.org/object-oriented-programming-in-cpp/
https://www.w3schools.com/cpp/cpp_oop.asp
+ 2
Highly recommended Youtube channel:
Christopher Okhravi
https://youtube.com/@christopherokhravi?si=BvkU5Id1zYyk_p6f
He explains many OOP concepts. Language does not really matter, Java or C# or C++ they almost all work similar, at least for the fundamental logic. There are some exceptions though, like in multiple inheritance.
0
I don’t know what a virtual function is, but it’s a shame they aren’t providing examples. About multiple inheritance: In Python (I’m guessing C++ is similar in structure), a class is a blueprint. You make objects from the blueprint. Inheritance is when you make a new class, but tell it to start off with the old one as sort of a template. You can redefine methods that were already defined in the base class, or leave them as is, and also define new methods. Basing a class on more than one other class makes it inherit all the method definitions from both base classes. If two or more of those base classes define the same method, the last one mentioned in the inheritance listing gets the last word, and its definition is the one the new class inherits. As for a real use example… I usually don’t need multiple inheritance, but I think I did run into it recently. Basically, it’s useful when a new class will have a lot of characteristics from two or more other classes already made before it.