Polymorphism in C++

后端 未结 7 1067
甜味超标
甜味超标 2020-11-22 09:01

AFAIK:

C++ provides three different types of polymorphism.

  • Virtual functions
  • Function name overloading
  • Operator overloading
7条回答
  •  借酒劲吻你
    2020-11-22 09:22

    If anybody says CUT to these people

    The Surgeon
    The Hair Stylist
    The Actor
    

    What will happen?

    The Surgeon would begin to make an incision.
    The Hair Stylist would begin to cut someone's hair.
    The Actor would abruptly stop acting out of the current scene, awaiting directorial guidance.
    

    So above representation shows What is polymorphism (same name, different behavior) in OOP.

    If you are going for an interview and interviewer asks you tell/show a live example for polymorphism in the same room we are sitting at, say-

    Answer - Door / Windows

    Wondering How?

    Through Door / Window - a person can come, air can come, light can come, rain can come, etc.

    i.e. One form different behavior(Polymorphism).

    To understand it better and in a simple manner I used above example.. If you need reference for code follow above answers.

提交回复
热议问题