Demonstrate Four OOP Principles
Model and implement a small C++ example that makes encapsulation, abstraction, inheritance and runtime polymorphism visible.
Explain the four pillars of object-oriented programming and demonstrate each in code.
For this exercise, assume you are building a small, in-process text-formatting demonstration. An object stores nonempty text. The demonstration supports two behaviors: rendering that text unchanged, and rendering it inside square brackets.
A caller must request rendering in the same way for either behavior, without checking the concrete type.
Objects can update their text. Reject empty initial text. Reject an empty update without changing the previous valid text. You may choose a constructor, factory, return value or exception to express the appropriate failures; make the contract clear.
Propose the objects, responsibilities and public contracts. Then write the central C++ code and a short client demonstration. Show where your design uses encapsulation, abstraction, inheritance and runtime polymorphism. Do not add persistence, networking, a user interface or concurrency.
The formatting example and its detailed rules are authored practice assumptions.