CPP 2201 Object Oriented Programming Study Notes

Examination Overview and Core OOP Principles

The CPP 2201: Object Oriented Programming examination, held in November 2025, covers fundamental concepts essential for software development. Abstraction simplifies systems by hiding complex implementation details, while encapsulation ensures data security by bundling data and methods within a class. Inheritance allows for code reusability by enabling derived classes to acquire properties from base classes. Polymorphism provides flexibility by allowing a single interface to represent multiple underlying forms. Transitioning from procedural programming to Object-Oriented Programming (OOP) offers distinct advantages in modularity and maintenance.

Advanced C++ Functions and Class Members

Within the C++C++ language, an inlineinline function is used to reduce function call overhead by replacing the call with the actual code during compilation. Conversely, a friendfriend function is a non-member function that possesses the authority to access private and protected data of a class. Static data members serve as shared variables among all objects of a class, ensuring that changes made by one instance are reflected across all others. Developers use function overloading to define multiple functions with the same name but different signatures, while operator overloading permits standard operators to perform operations on user-defined types.

Class Lifecycle and Inheritance Hierarchies

Constructors, such as a parameterized constructor, are essential for object initialization during creation, following the syntax ClassName(parameters){}ClassName(parameters) \{\}. Destructors, denoted by the syntax ∼ClassName(){}\sim ClassName() \{\}, automate resource cleanup when an object goes out of scope. Inheritance hierarchies, such as multilevel inheritance involving PersonPerson, EmployeeEmployee, and ManagerManager classes, demonstrate how attributes and display functions are passed down and extended. While inheritance defines an "is-a" relationship, composition defines a "has-a" relationship, where a class contains objects of another class to build complex structures.

Runtime Polymorphism and Design Standards

Runtime polymorphism is achieved through virtual functions, which enable dynamic binding so that the appropriate member function is called at execution time. Proper data hiding in classes like VehicleVehicle involves making attributes like brandbrand private and providing public accessors, such as setBrand(string b)setBrand(string\,b) and getBrand()getBrand(). High-quality object-oriented design is identified by three main characteristics: low coupling between components, high cohesion within modules, and clear abstraction to ensure the system remains scalable and manageable.