V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
yakczh

go语言为什么没有继承?

  •  
  •   yakczh · Jan 2, 2013 · 3886 views
    This topic created in 4873 days ago, the information mentioned may be changed or developed.
    看了一下其他方面都很不错,但没有继承,光有接口的话,那相同的类属性,是不是都要重复声明?
    6 replies    1970-01-01 08:00:00 +08:00
    reusFork
        1
    reusFork  
       Jan 2, 2013
    不需要,因为有embedded struct
    raspberry
        2
    raspberry  
       Jan 2, 2013
    struct有匿名字段可用
    notedit
        3
    notedit  
       Jan 2, 2013
    type A struct {
    }

    type B struct {
    A
    }
    wildchild
        4
    wildchild  
       Jan 2, 2013
    细追究它还没有类呢,呵呵,实现面向对象的不同方式了。
    daweiba
        5
    daweiba  
       Jan 3, 2013
    3楼正解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   968 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 22:19 · PVG 06:19 · LAX 15:19 · JFK 18:19
    ♥ Do have faith in what you're doing.