Contenido del Curso
C++ OOP
C++ OOP
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.
¡Gracias por tus comentarios!