package main
import (
"fmt"
)
type Phone interface {
call()
}
type NokiaPhone struct {
}
func (nokiaPhone NokiaPhone) call() {
fmt.Println("I am Nokia, I can call you!")
}
type IPhone struct {
}
func (iPhone IPhone) call() {
fmt.Println("I am iPhone, I can call you!")
}
func main() {
var phone Phone
phone = new(NokiaPhone)
phone.call()
phone = new(IPhone)
phone.call()
}
Go 接口
GO相关文章
最近热门
- 常见的深度学习优化器Optimizer
- 论文 | DHEN: A Deep and Hierarchical Ensemble Network for Large-Scale Click-Through Rate Prediction
- GradNorm
- SO-PMI(Semantic Orientation Pointwise Mutual Information,情感倾向点互信息算法)
- kimi api
- NPU(Neural Processing Unit,神经网络处理器)
- vue3 vditor
- Straight-Through Estimator(STE, 直推估计器)
- 流匹配(Flow Matching,FM)
- 模型证据下界(Evidence Lower Bound,ELBO)
最常浏览
- 016 推荐系统 | 排序学习(LTR - Learning To Rank)
- 偏微分符号
- i.i.d(又称IID)
- 利普希茨连续条件(Lipschitz continuity)
- (error) MOVED 原因和解决方案
- TextCNN详解
- 找不到com.google.protobuf.GeneratedMessageV3的类文件
- Deployment failed: repository element was not specified in the POM inside distributionManagement
- cannot access com.google.protobuf.GeneratedMessageV3 解决方案
- CLUSTERDOWN Hash slot not served 问题原因和解决办法
×