Object Oriented Programming
Object Oriented Programming
But before we can create objects and use them in C++, we first need to learn
about classes.
C++ Class
class className {
// some data
// some functions
};
Here, we defined a class named Room.
The variables length, breadth, and height declared inside the class are known as data members. And, the
functions calculateArea() and calculateVolume() are known as member functions of a class.
C++ Objects
• Before we learn about the protected access specifier, make sure you
know about inheritance in C++.
• The protected keyword is used to create protected members (data
and function).
• The protected members can be accessed within the class and from
the derived class.
Inheritance
A class can also be derived from one class, which is already derived
from another class.