0% found this document useful (0 votes)
9 views

OOP C++ Notes

Uploaded by

alyackerman6
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

OOP C++ Notes

Uploaded by

alyackerman6
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Detailed Notes on Object Oriented Programming using C++

Introduction to OOP

Object-Oriented Programming (OOP) is a programming paradigm that uses 'objects' to represent

data and methods to manipulate that data. OOP contrasts with Procedure-Oriented Programming

(POP), where the focus is on functions.

Key Concepts of OOP

The four fundamental principles of OOP are:

1. **Abstraction**: Hiding the complex reality while exposing only the necessary parts.

2. **Encapsulation**: Bundling the data and methods that operate on the data within one unit, or

class.

3. **Inheritance**: Mechanism by which one class can inherit the properties and methods of another.

4. **Polymorphism**: Ability to present the same interface for different underlying forms (data types).

Objects and Classes

A class is a blueprint for creating objects. Objects are instances of classes that encapsulate both

data and methods that operate on that data. In C++, classes are defined using the 'class' keyword.

Constructors and Destructors

A constructor is a special member function that initializes objects of a class. It has the same name

as the class and is invoked when an object is created. A destructor is also a special member

function that is called when an object goes out of scope and is used to free resources.

Access Specifiers

Page 1
Detailed Notes on Object Oriented Programming using C++

C++ provides three access specifiers:

1. **Public**: Members declared as public are accessible from outside the class.

2. **Private**: Members declared as private are accessible only within the class.

3. **Protected**: Members declared as protected are accessible in the class and in derived classes.

Inheritance

Inheritance allows a class to use properties and methods of another class. It helps in reusability of

code. Types of inheritance include single inheritance, multiple inheritance, and multilevel

inheritance.

Polymorphism

Polymorphism allows methods to do different things based on the object it is acting upon. It can be

achieved through function overloading (compile-time polymorphism) and function overriding (runtime

polymorphism).

Conclusion

OOP enhances the clarity and maintainability of code. By encapsulating data and functions together,

it helps model real-world entities more effectively.

Page 2

You might also like