美文网首页Go
Is Go an object-oriented languag

Is Go an object-oriented languag

作者: Hifun丶 | 来源:发表于2019-11-16 15:30 被阅读0次

Yes and no. Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy. The concept of “interface” in Go provides a different approach that we believe is easy to use and in some ways more general. There are also ways to embed types in other types to provide something analogous—but not identical—to subclassing. Moreover, methods in Go are more general than in C++ or Java: they can be defined for any sort of data, even built-in types such as plain, “unboxed” integers. They are not restricted to structs (classes).
Also, the lack of a type hierarchy makes “objects” in Go feel much more lightweight than in languages such as C++ or Java.

相关文章

网友评论

    本文标题:Is Go an object-oriented languag

    本文链接:https://www.haomeiwen.com/subject/npuyictx.html