3. MODULE OUTCOME
1. Students must be able to understand the fundamentals of OOP
2. Students must practically experience OOP with C++ programming language
5. INTRODUCTION TO OOP
• Programming paradigm that uses objects as fundamental building blocks of a software
application
• Objects are instances of classes. A class is a blueprint or template that defines the structure and
behavior of objects. For instance,
Person
-Name
-Age
-StudentID
-Major
Studen
t
-Person is the base class with attributes name
and age.
-Student is the derived class (a subclass of
Person) and inherits the attributes name and
age from the base class. Additionally, it has its
specific attributes, such as studentID and major
6. How to build classes and objects in C++
Source code
Output
Exercise
Add the second Employee with the
following details
Name: Ammar
Company: AIMST University
Age: 39
7. What are Constructors
Example
Special type of method that is invoked
each time an object of a class is
created
There are two constructors
- Default constructor
- Parameterized constructor
The parameterized constructor allows
you to specify the values during object
creation.
8. What is Encapsulation
Example
Encapsulation is wrapping of data a single unit
called class
It involves hiding the internal details of a class and
providing controlled access to its members (data
and functions)
Make the data members (e.g., Name and Age)
private, so they cannot be directly accessed from
outside the class.
Provide public member functions (getters and
setters) to access and modify these private data
members
Output