Abstraction
beginnerAbstraction hides complex implementation details and shows only the essential features of an object.
Two Levels of Abstraction
- Class abstraction: Hide implementation behind a clean interface
- Physical abstraction: Abstract base classes with pure virtual functions
Why Abstract?
- Reduce complexity for the user
- Focus on WHAT an object does, not HOW
- Allow implementation changes without breaking code
Example
A car driver uses steering wheel and pedals (interface) without knowing how the engine works (implementation).
Abstract Classes
- Contain at least one pure virtual function (= 0)
- Cannot be instantiated directly
- Serve as templates for derived classes
Interfaces in C++
An interface is a class with ONLY pure virtual functions. C++ doesn't have a separate interface keyword, but this pattern is common.
Key takeaway: Abstraction hides complexity behind a clean interface — use abstract classes and pure virtual functions to define contracts that derived classes must follow.