Where did the concept of Interfaces come from?

后端 未结 18 2108
有刺的猬
有刺的猬 2021-01-11 18:45

In c#, we have interfaces. Where did these come from? They didn\'t exist in c++.

18条回答
  •  说谎
    说谎 (楼主)
    2021-01-11 19:35

    Interfaces existed in C++ if you did COM programming, which is where the IPrefix convention originates.

    Although C++ itself didn't natively support interfaces, COM/C++ used type libraries generated from Interface Definition Language which has the only purpose of defining interfaces, and used the interface keyword long before Java or C# did.

    Aside from allowing a form of multiple inheritence, .NET's motivation for interfaces have to do with its component-oriented origins and its main purpose is to define contracts between components that can interoperate without any knowledge of each other's implementations. Some COM interop is also done with .NET interfaces.

提交回复
热议问题