Sams Teach Yourself C++ in 21 Days

(singke) #1
Getting Started 9

1


In turn, obtaining each employee’s record can be broken down into the following:



  1. Open the file of employees.

  2. Go to the correct record.

  3. Read the data.


Structured programming remains an enormously successful approach for dealing with
complex problems. By the late 1980s, however, some of the deficiencies of structured
programming had become all too clear.


First, a natural desire is to think of data (employee records, for example) and what you
can do with that data (sort, edit, and so on) as a single idea. Unfortunately, structured
programs separate data structures from the functions that manipulate them, and there is
no natural way to group data with its associated functions within structured program-
ming. Structured programming is often called procedural programmingbecause of its
focus on procedures (rather than on “objects”).


Second, programmers often found themselves needing to reuse functions. But functions
that worked with one type of data often could not be used with other types of data, limit-
ing the benefits gained.


Object-Oriented Programming (OOP) ..............................................................


Object-oriented programming responds to these programming requirements, providing
techniques for managing enormous complexity, achieving reuse of software components,
and coupling data with the tasks that manipulate that data.


The essence of object-oriented programmingis to model “objects” (that is, things or con-
cepts) rather than “data.” The objects you model might be onscreen widgets, such as but-
tons and list boxes, or they might be real-world objects, such as customers, bicycles,
airplanes, cats, and water.


Objects have characteristics, also called properties or attributes, such as age, fast, spa-
cious, black, or wet. They also have capabilities, also called operations or functions, such
as purchase, accelerate, fly, purr, or bubble. It is the job of object-oriented programming
to represent these objects in the programming language.


C++ and Object-Oriented Programming ............................................................


C++ fully supports object-oriented programming, including the three pillars of object-
oriented development: encapsulation, inheritance, and polymorphism.

Free download pdf