Object-Oriented Programming Tutorials in C++, Java and Python

Flat UML class diagram illustration showing parent and child class inheritance hierarchy with polymorphism symbol and encapsulation padlock icon in blue and white

Object-oriented programming (OOP) organizes software around objects that combine data with the code that changes it. These tutorials teach each OOP concept with the same examples in C++, Java and Python, so you can see what is common to all three languages and where they differ. Every program is compiled and run with GCC, Clang, Java 21 and Python 3, and the code is in the MYCPLUS examples repository on GitHub.

Start here: Object-Oriented Programming: Concepts, Pillars and Techniques explains all six concepts with one example, compares OOP with procedural code, and introduces SOLID and design patterns.

The OOP concepts, in reading order

  1. Classes: fields, methods, constructors and static members, and why a list in a Python class body is shared by every object.
  2. Objects: state, behavior and identity, equality versus identity, shallow and deep copies, and object lifetime.
  3. Encapsulation: private state, invariants, how a getter can leak data, and Python properties.
  4. Abstraction: abstract classes, interfaces, Python ABCs and protocols, and leaky abstractions.
  5. Inheritance: the five types, overriding, the fragile base class problem, and when composition is better.
  6. Polymorphism: overloading, overriding, virtual functions, generics and duck typing.

Object-oriented programming in C++

Scroll to Top