Virtual/pure virtual explained

后端 未结 12 1473
暖寄归人
暖寄归人 2020-11-22 01:31

What exactly does it mean if a function is defined as virtual and is that the same as pure virtual?

12条回答
  •  故里飘歌
    2020-11-22 02:17

    Simula, C++, and C#, which use static method binding by default, the programmer can specify that particular methods should use dynamic binding by labeling them as virtual. Dynamic method binding is central to object-oriented programming.

    Object oriented programming requires three fundamental concepts: encapsulation, inheritance, and dynamic method binding.

    Encapsulation allows the implementation details of an abstraction to be hidden behind a simple interface.

    Inheritance allows a new abstraction to be defined as an extension or refinement of some existing abstraction, obtaining some or all of its characteristics automatically.

    Dynamic method binding allows the new abstraction to display its new behavior even when used in a context that expects the old abstraction.

提交回复
热议问题