Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Why use Object-Oriented Programming? | Fundamentals of OOP
C++ OOP
course content

Зміст курсу

C++ OOP

C++ OOP

1. Fundamentals of OOP
2. Constructors and Destructors
3. Encapsulation Overview
4. Inheritance Overview
5. Polymorphism Overview

book
Why use Object-Oriented Programming?

It is quite simple to create a comparison between Procedural programming and Object-Oriented Programming (OOP). To grasp this comparison better, let's delve into the key characteristics of each approach:

Why it is important to bundle data

Consider the task of developing a software application for managing students' data, it might seem straightforward at first. For example, you could start with a simple structure to store a student's name and their grade point average (gpa). Here's a basic illustration:

This approach is fine when dealing with a single student. However, complexities arise when you want to manage multiple students. A naive approach might involve creating separate variables for each student:

This method quickly becomes unmanageable as the number of students increases. Using arrays can help reduce repetition, but what if you need to expand the data you store for each student? Let's say you want to add email addresses:

The solution to these issues lies in Object-Oriented Programming (OOP) because it allows you to create a Student class, a blueprint for student objects. It can store all the relevant information (like name, gpa, and email) and behaviors of a student.

Note

While you can use struct to achive similar goals, it cannot fully replace Object-Oriented Programming. We will dive into a more comprehensive explanation of this distinction later in the course.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 2
We're sorry to hear that something went wrong. What happened?
some-alt