Home TechnologyProgrammingC++ Subscribe to RSS

What Is The Concept Of Overloading, Overriding, Encapsulation, Abstraction With Code In C++ And C#?

Answer Question

1 Answer - Sort by: Date | Rating

    Operator overloading allows programmers to use the existing operators so that they can be used with user defined data types. The programmer provides a function definition to that specifies the return data type followed by keyword 'operator ' and the operator that is to be overloaded. Then the operation of the operator is defined in the body of that function and the operands are provided as arguments to the function. For example, plus operator will be overloaded for an object of class point having data members x and y as follows:
       point operator+(point p1)
         {
             point temp;
             temp.x=x+p1.x;
             temp.y=y+p1.y;
             return point;
          }
    Overriding is the process of defining a function in the child class with same name. In this way the child class method hides parent class method. Method overriding is used to provide different implementations of a function so that a more specific behavior can be realized.

    Perhaps the most important concept of object orientation is abstraction. The basic idea of abstraction is to hide the low-level implementation details and to provide a simple interface. It provides two important benefits. One is the simplicity and clarity of coding and second is the ease of modification.

      Encapsulation is used to implement abstraction. In encapsulation we combine the data and methods that operate on the data and put them in a single unit. An interface is provided to interact with this unit. An example of abstraction is the class definition in which data and methods are combined together.
    0 0

    Raaga 

    answered 3 years ago

    Good explanation!!!1thanks a lot
    Report
    Sagarbhai

    Sagarbhai

    commented 9 months ago

    Good Explanation!
    Report
    Felishia

    Felishia

    commented 6 months ago

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International