Important Announcement
Random Post winner - Total Prize $5                               
 Place your AD Here for US$ 150/Month Only.
 Place your AD Here for US$ 150/Month Only.
Place your AD Here for US$ 75/Month Only.
Place your AD Here for US$ 75/Month Only.
1 Advertise Here for US$ 350/Month.
2
3 Advertise Here for US$ 330/Month.
4 Advertise Here for US$ 320/Month.
5
Advertise Here for US$ 310/Month with Incremental value of US$ 10/Upper Slot.
Disclaimer: GlobaEarnTalk does not have any affiliation with any advertising sites. We do not endorse any advertisement.
GET Notice Board
(?`*• New FuN to EarN will be launched soon. So stay tuned to GET the most of them. •*`?)
Results 1 to 8 of 8

Thread: Polymorphism

  1. Default Re: Polymorphism

    Basically, it is the capacity to appear in altered forms.In object-oriented programming, polymorphism mention to a programming language's capability to process objects variously depending on their data type or class.

  2. #2

    Default Re: Polymorphism

    Polymorphism is the ability to use an operator or method in different ways. Polymorphism gives different meanings or functions to the operators or methods. Poly, referring to many, signifies the many uses of these operators and methods. A single method usage or an operator functioning in many ways can be called polymorphism. Polymorphism refers to codes, operations or objects that behave differently in different contexts.

    Ads

    Below is a simple example of the above concept of polymorphism:

    6 + 10

    The above refers to integer addition.

    The same + operator can be used with different meanings with strings:

    "Exforsys" + "Training"

    The same + operator can also be used for floating point addition:

    7.15 + 3.78

    Polymorphism is a powerful feature of the object oriented programming language C++. A single operator + behaves differently in different contexts such as integer, float or strings referring the concept of polymorphism. The above concept leads to operator overloading. The concept of overloading is also a branch of polymorphism. When the exiting operator or function operates on new data type it is overloaded. This feature of polymorphism leads to the concept of virtual methods.

    Polymorphism refers to the ability to call different functions by using only one type of function call. Suppose a programmer wants to code vehicles of different shapes such as circles, squares, rectangles, etc. One way to define each of these classes is to have a member function for each that makes vehicles of each shape. Another convenient approach the programmer can take is to define a base class named Shape and then create an instance of that class. The programmer can have array that hold pointers to all different objects of the vehicle followed by a simple loop structure to make the vehicle, as per the shape desired, by inserting pointers into the defined array. This approach leads to different functions executed by the same function call. Polymorphism is used to give different meanings to the same concept. This is the basis for Virtual function implementation.

    In polymorphism, a single function or an operator functioning in many ways depends upon the usage to function properly. In order for this to occur, the following conditions must apply:

    All different classes must be derived from a single base class. In the above example, the shapes of vehicles (circle, triangle, rectangle) are from the single base class called Shape.
    The member function must be declared virtual in the base class. In the above example, the member function for making the vehicle should be made as virtual to the base class.

    Features and Advantages of the concept of Polymorphism:
    Applications are Easily Extendable:

    Once an application is written using the concept of polymorphism, it can easily be extended, providing new objects that conform to the original interface. It is unnecessary to recompile original programs by adding new types. Only re-linking is necessary to exhibit the new changes along with the old application. This is the greatest achievement of C++ object-oriented programming. In programming language, there has always been a need for adding and customizing. By utilizing the concept of polymorphism, time and work effort is reduced in addition to making future maintenance easier.

    Helps in reusability of code.
    Provides easier maintenance of applications.
    Helps in achieving robustness in applications.

    Types of Polymorphism:

    C++ provides three different types of polymorphism.

    Virtual functions
    Function name overloading
    Operator overloading

    In addition to the above three types of polymorphism, there exist other kinds of polymorphism:

    run-time
    compile-time
    ad-hoc polymorphism
    parametric polymorphism


    cegonsoft

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •