代码之家  ›  专栏  ›  技术社区  ›  therealhoff

接口概念是从哪里来的?

  •  10
  • therealhoff  · 技术社区  · 16 年前

    在C中,我们有接口。这些是从哪里来的?它们在C++中是不存在的。

    18 回复  |  直到 16 年前
        1
  •  10
  •   Scott Wisniewski    16 年前

        2
  •  5
  •   17 of 26    16 年前

        3
  •  3
  •   FlySwat    16 年前

    public class Dog : Animal, IMammal
    

    public class Dog extends Animal implements IMammal
    

        4
  •  3
  •   Jason Baker    16 年前
        5
  •  2
  •   Mark Cidade    16 年前

        6
  •  1
  •   Ben Hoffstein    16 年前

        7
  •  1
  •   moffdub    16 年前

        9
  •  1
  •   who    16 年前

        10
  •  1
  •   BBetances    16 年前

    static string Method(int i)
    

        11
  •  0
  •   Charles Graham    16 年前

        12
  •  0
  •   Statement    16 年前

    class IFoo
    {
    public:
      void Bar() =0;
      void Bar2() =0;
    };
    
    class Concrete : public IFoo
    {
    public:
      void Bar() { ... }
      void Bar2() { ... }
    }
    
        13
  •  0
  •   Massimiliano    16 年前

    class IExecutable
    {
    public:
        virtual void Execute() = 0;
    };
    
    class MyClass : public IExecutable
    {
    public:
        void Execute() { return; };
    };
    

    public interface IPurring
    {
        void Purr();
    }
    
    public class Cat : Animal, IPurring
    {
        public Cat(bool _isAlive)
        {
            isAlive = _isAlive;
        }
    
        #region IPurring Members
    
        public void Purr()
        {
            //implement purring
        }
    
        #endregion
    }
    
        14
  •  0
  •   kenny    16 年前

        15
  •  0
  •   Brian Rasmussen    16 年前

        17
  •  -4
  •   Ian P    16 年前

        18
  •  -5
  •   user17000    16 年前