Friday, 13 December 2013

oops with c++

Data abstraction:

  •  Data abstraction is the key feature of oops.It can also be known as data hiding.
  • The process of representing the essential features of a class without including background details.
  • Example:
                    class sample
                    {    
                             public:
                                          void fun();
                                          void welcome();
                     };

In the above example, the member functions fun() and welcome() has been declared. The definitions of those function is hidden. This is known as data hiding or data abstraction.

Data hiding or abstraction achieves in creating security of data.

Data encapsulation:
  • The process of binding up of data and functions into a single entity.
  • Real time example: pen.
Inheritance:
·         The process of creating  a new class from an existing class or an old class is known as inheritance.
·         (i.e),The new class can be derived from an existing class. 
·          The new class is called as derived class or child class and the existing class is called as base class or parent class.
·         This process of inheriting a class is also called as specialization. 
·         This achieves in reusability.


 


Syntax for derived class:

class der_class_name : visibility_mode base class_name

Example:

Class derived : public base

Where derived is the name of derived class and base is the name of the base class. when the class is declared and derived with the access specifier PUBLIC, it can be used anywhere in the program.



Polymorphism:

  • The ability to respond differently to different objects or function
  • Real time example:
               Consider a child as a object.A child has to act as a son/daughter in home,and student in school, and well wisher to the society.

              Thus,depending upon the situation or a place, the characteristics of a child changes, this property is known as polymorphism.


No comments:

Post a Comment