当前位置:   article > 正文

go struct转interface_Go 语言面向对象开发

go struct转interface_Go 语言面向对象开发
面向对象什么呢?

面向「对象」应该是。。。。 此处应该有表情包,但是。。。。

面向对象是一种编码思想,简单来说就是将实体对应成一个实体的对象,解释概念有些没什么实际作用。这里就直接一点,面向对象最重要的两个概念就是对象和类。面向对象最基本特征就是封装,继承,抽象,多态。这四个特征是面向对象的基石。

前言

Go 语言是面向对象语言吗?

我们来看看 go 语言官方解释:

Is Go an object-oriented language? 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).

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/907896
推荐阅读
相关标签
  

闽ICP备14008679号