zoukankan      html  css  js  c++  java
  • 抽象类

    # class Animal:
    # def eat(self):
    # pass
    # def run(self):
    # pass
    #
    # class People(Animal):
    # def eat(self):
    # print('people is eating')
    # def run(self):
    # print('people is running')
    # class Pig(Animal):
    # def eat(self):
    # print('pig is eating')
    # def run(self):
    # print('pig is running')
    #
    # peo1=People()
    # pig1=Pig()
    #
    # peo1.eat()
    # pig1.eat()

    # import abc
    #
    # class Animal(metaclass=abc.ABCMeta):
    # @abc.abstractmethod
    # def eat(self):
    # pass
    #
    # @abc.abstractmethod
    # def run(self):
    # pass
    #
    #
    # class People(Animal):
    # def eat(self):
    # # print('people is eating')
    # pass
    #
    # def run(self):
    # # print('people is running')
    # pass
    #
    # class Pig(Animal):
    # def eat(self):
    # pass
    #
    # def run(self):
    # pass
    #
    # peo1=People()
    # peo1.eat()
    #
    # pig1=Pig()
    # pig1.eat()

    # import abc
    #
    # class File(metaclass=abc.ABCMeta):
    # @abc.abstractmethod
    # def eat(self):
    # pass
    #
    # @abc.abstractmethod
    # def run(self):
    # pass
    #
    # class Disk(File):
    # def read(self):
    # print('disk read')
    # def write(self):
    # print('disk write')
    #
    # class Process(File):
    # def read(self):
    # print('process read')
    # def write(self):
    # print('process write')
    #
    # d=Disk()
    # p=Process()
    #
    # d.read()
    # d.write()
    #
    # p.read()
    # p.write()
  • 相关阅读:
    java--exceptions
    java-interface
    Java笔记
    memcpy
    const 关键字
    LeeCode整数 反转
    函数调用运算符笔记
    cvCreateImage
    c++继承笔记1
    虚拟机下的debian无法登陆
  • 原文地址:https://www.cnblogs.com/0B0S/p/12084675.html
Copyright © 2011-2022 走看看