V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
yakczh
V2EX  ›  Go 编程语言

go语言为什么没有继承?

  •  
  •   yakczh · 2013-01-02 18:02:09 +08:00 · 3078 次点击
    这是一个创建于 4145 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看了一下其他方面都很不错,但没有继承,光有接口的话,那相同的类属性,是不是都要重复声明?
    6 条回复    1970-01-01 08:00:00 +08:00
    reusFork
        1
    reusFork  
       2013-01-02 18:03:18 +08:00
    不需要,因为有embedded struct
    raspberry
        2
    raspberry  
       2013-01-02 18:20:33 +08:00
    struct有匿名字段可用
    notedit
        3
    notedit  
       2013-01-02 21:51:01 +08:00
    type A struct {
    }

    type B struct {
    A
    }
    wildchild
        4
    wildchild  
       2013-01-02 21:55:06 +08:00
    细追究它还没有类呢,呵呵,实现面向对象的不同方式了。
    daweiba
        5
    daweiba  
       2013-01-03 03:56:55 +08:00
    3楼正解
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   966 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:21 · PVG 05:21 · LAX 14:21 · JFK 17:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.