zoukankan      html  css  js  c++  java
  • golang 自定义接口 和 实现接口

     1 /*
     2     定义:
     3     type 接口名 interface{
     4         方法名(可选:参数列表) 可选:返回值列表 || (可选:返回值列表)
     5     }
     6     例:type Writer interface {
     7         Write(p []byte) (n int, err error)
     8     }
     9     type Objecter interface{//定义接口
    10         say(class int, value string) (b bool, err error)
    11     }
    12     实现接口:
    13         1:接口的方法与实现接口的类型方法格式一致
    14         2:当一个接口中有多个方法时,只有这些方法都被实现了,接口才能被正确编译并使用
    15 */
    16 
    17 package info_interface
    18 
    19 import "fmt"
    20 
    21 func Say(){
    22     fmt.Println("info_interface")
    23 }
  • 相关阅读:
    15-数组concat()方法和push比较
    06-使用云储存上传工具
    05-云函数/云数据库的增删改查
    错题1
    c++链表
    8817
    8816
    1177
    1355
    c++期末考
  • 原文地址:https://www.cnblogs.com/weihexinCode/p/12317064.html
Copyright © 2011-2022 走看看