C + +: Display interface & Run-time polymorphism and implicit interface & compile-time polymorphism

Source: Internet
Author: User

Class and Object oriented:

Display interface (explicit interface): that is, visible in the source code, you can see all the interfaces of the class in the header file;

Run-time polymorphism (Runtime polymorphism): A member function is virtual, when a reference or pointer to a class is passed, the interface is automatically matched at run time, possibly the interface of a base class, or a derived class;

Template (templates) and generic programming (generic programming):

Implicit interface (implicit interface): TypeName T, in a function, must support a set of operations, only to support these operations in order to compile;

Compile-time polymorphism (Compile-time polymorphism): a template (template)-instantiated (instantiated) function template (function templates), similar to overloads, is bound at compile time.

In an implicit interface, overloads, such as operators, already contain implicit type conversions.

If the program can be compiled, whether it is a class or a template, you need to pass through polymorphism to meet the requirements of the interface, otherwise can not be compiled.

Author: csdn Blog spike_king

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/cplus/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.