Where did the concept of Interfaces come from?

后端 未结 18 2257
有刺的猬
有刺的猬 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:12

    Well there wasn't any language integrated mechanism syntax for it, but you can achieve interfaces in C++ with pure virtual classes.

    class IFoo
    {
    public:
      void Bar() =0;
      void Bar2() =0;
    };
    
    class Concrete : public IFoo
    {
    public:
      void Bar() { ... }
      void Bar2() { ... }
    }
    

提交回复
热议问题