Vous êtes sur la page 1sur 2

• Class: - A class is a user defined data type which holds both the data and functions.

• The internal data of a class is called member data (or data member) and the functions
are called member functions.
• The variables of a class are called objects or instances of a class.
• Class is useful to combine the data and operations of a structure into a single entity.
• The class construct provides support for data hiding , abstraction, encapsulation,
single inheritance, multiple inheritance, polymorphism and public interface functions
(methods) for passing message between objects.
• Data abstraction: - In OOPS the data abstraction is defined as a collection of data
and methods (functions)
• Data hiding: - In C++, the class construct allows to declare data and methods, as a
public, private and protected group. The implementation details of a class can be
hidden. This is done by the data hiding principle.
• Data encapsulation: - The internal data (the member data) of a class are first
separated from the outside world (the defined class). They are then put along with
the member functions in a capsule. In other words, encapsulation groups all the
pieces of an object into one neat package. It avoids undesired side effects of the
member data when it is defined out of the class and also protects the intentional
misuse of important data, classes efficiently manage the complexity of large
programs through encapsulation.
• Inheritance: - C++ allows a programmer to build hierarchy of classes. The
derivation of classes is used for building hierarchy. Th basic features of classes
(parent classes or basic classes) can be passed onto the derived classes (child
classes). In practice, the inheritance principle reduces the amount of writing; as
the derived classes do not have to be written again.
• Polymorphism: - In OOPS, polymorphism is defined as how to carry out different
processing steps by a function having the same messages. Polymorphism treats
objects of related classes in a generic manner.
• The terminology in OOP’s, that is equal to the terminology of function, oriented
programming.

Function oriented Object oriented


programming programming
User defined types Classes
Variables Objects
Structure members Instance variables
Functions Methods
Function call Message passing.

Structures and Classes: -

The structure contains one or more data items (called members) which are
grouped together as a single unit. A class is similar to structure data type but it consists of
not only data elements but also functions, which are operated on the data elements.
secondly, in a structure, all elements are public by default, while in class it is private and
the functions can be defined as public, private or protected.