Header Ads Widget

Concept of C++ programming language || Class, Object, Encapsulation, Inheritance, Polymorphism

 

Concept of C++ programming language

In C++ language provide a lot of features and all features concept having its own behavior. They are:-

    



Class

Class is user defined data types which have its own data member and member function. In other word we can say class is collection of data member and member function which can accessed and use by creating object of that class.

For example: cars, bikes

Syntax:-

Class class_name
{

                        Access specifier:
                        Data member;
                        Member function;

}

Object

An object is a definition of any class where object allocate the memory location to perform any task. Without class it doesn’t any meaning.

For example: BMW, Honda

Syntax:-

            class_name   object_name;

 

Abstraction

Abstraction may be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details. For example: A car is viewed as a car rather than its individual component.

Abstraction can be implemented: -
                                                              class
                                                              Header file

Program:-

#include <math.h>
#include<iostream>
main()
  {        
            int a=2,b;
            b=sqrt(a);
            cout<<b;
}

 

Encapsulation

Encapsulation is define as the wrapping the data and function into a single unit. The data of class is not accessible to outside the class only those function access data which are wrapped in the class.

 For example: class is an example of encapsulation which binds the data member and member function together that manipulates these data.

Inheritance

Inheritance is procedure in which one class inherits the property of other class. The class whose properties are inherited is known as parent class. And the class that inherits the properties from the parent class is known as child class.

 

Polymorphism

Polymorphism is defined as to perform a single action in different way. It is combined with word “poly” means many and another is “morphism” means forms.





Post a Comment

0 Comments