Data Abstraction & Classes
• Data abstraction
• Data members and member functions
• Information hiding
A Brief History of C++
• Bjarne Stroustrup of AT&T Bell Labs extends C with Simula-like
classes in the early 1980s, and the new language was called ”C
• C++, the successor of ”C with Classes”, was designed by Strous-
trup in 1986, and version 2.0 was introduced in 1989.
The design of C++ was guided by the following three principles:
1. The use of classes would not result in programs executing any
more slowly than programs not using classes.
2. C programs should run as a subset of C++ programs.
3. No run-time inefficiency should be added to the language.
• What is a “chair”?
• What is a “stack”?
A data abstraction is a simplified view of an object that includes
only features one is interested in while hides away the unnecessary
In programming languages, a data abstraction becomes an
abstract data type or a user-defined type.
In OOP, it is implemented as a class.
Example: Implement a Stack with an Array
Example: Implement a Stack with a Linked List
• An abstract specification tells us the behavior of an object inde-
pendent of its implementation. i.e.
It tells us what an object
does independent of how it works.
• Information hiding is also known as data encapsulation, or
• The principle of information hiding:
Design a program so that the implementation of an object can
be changed without affecting the rest of the program.
e.g. Changing the implementation of a stack from an array to a
linked list has no effect on users’ programs.
Example: stack ar.h
Object pop( );
// basic operations
// status operations