+ 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...

24th May 2024, 5:06 PM
Alok
Alok - avatar
3 Réponses
25th May 2024, 1:45 AM
Chris Coder
Chris Coder - avatar
+ 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.
26th May 2024, 4:29 AM
Tibor Santa
Tibor Santa - avatar
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.
24th May 2024, 8:56 PM
Wilbur Jaywright
Wilbur Jaywright - avatar