Monday 24 February 2014

C++ Object-Oriented Concepts

Here are few principle concepts that form the foundation of object-oriented programming:

Object:

This is the basic unit of object oriented programming. Material information as it comes bundled as a unit operates on both the data and function.

Class:

When you define a class, you can specify a blueprint for an object. This fact, I do not know of any data, but they do not know what that means the layer name, that is, an object of the class will consist of and what operations can be performed on such an object.

Class is behavior of data and function. data and function is operate only into Class.
Class has many object ( for ex man, female)

    1) data object--> public int id;
    2) function object--> public void getdata(),


Abstraction:

Data abstraction is concerned, providing critical information for foreign words and hide the details of the background, i.e., to represent the necessary information in program without presenting the details.

For example, a database hides certain details. How data is stored and created and maintained. example of color is abstracted to RGB. By just making the combination of these three colors we can achieve any color in the world.

Abstraction :-> provide some information & hide unrelieved information.

public, privet, protected use abstract information.

Encapsulation:

It is hiding all the complex processing from outside world and making your objects simple.

Inheritance:

concept of inheritance help to define parent child relationship between classes. This concept very useful to oops . In future its reduce code size.

one class information use in another class so reduce code size.
  1)singe level inheritance :-->means supper class, class A derive only class B subclass.

   
  2) multilevel inheritance(multi level not use in C#) but use interface we can create multi level interface.

Polymorphism:

It means name of the function same but implementation in many form.poly is refer to many.That is a single function or an operator functioning in many ways different  usage is called polymorphism.

There are two type polymorphism.

  1) Static polymorphism --> In static a) function overloading.
                                                            b) operator overloading.
       Overloading decide  at compile time. In static function name same parameters are different but function name is same.
for example.      add(2,4)
                          add(5.6,7.9)   from both of which you want to its decide at compile time.

  2) Dynamic polymorphism--> In Dynamic a) Virtual function.
                                                                         b) Abstraction function.


         Overriding decide at run time .in dynamic function name and parameter both are same.

for example.    class emp-->actual sal
                            {
                                     accept()
                                    {

                                    }

                           
                           accept()
                              { 

                                 }
                         }
two accept here but which one is run that decide at runtime.

0 comments:

Post a Comment