How do Concepts differ from Interfaces?

后端 未结 4 1820
栀梦
栀梦 2020-12-15 04:22

How do Concepts (ie those recently dropped from the C++0x standard) differ from Interfaces in languages such as Java?

4条回答
  •  情书的邮戳
    2020-12-15 05:20

    Concepts are likes types (classes) for templates: it's for the generic programming side of the language only.

    In that way, it's not meant to replace the interface classes (assuming you mean abstract classes or other C++ equivalent implementation of C# or Java Interfaces) as it's only meant to check types used in template parameters to match specific requirements. The type check is only done at compile time like all the template code generation and whereas interface classes have an impact on runtime execution.

提交回复
热议问题