课程: Treating Go as an Object-Oriented Language
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Creating a struct
- [Instructor] So now it's time to create a struct together in our IVs. So I want you to open up the exercise files to the beginning of this and you'll have an empty project other than a few read mes and other things. We are going to create a file and it's going to be called main.go right at the root. Now I'm going to rename the package here to main and I'm going to create a main function and we'll leave it empty for right now. We will get to that here in a little bit. Now we're going to create a new directory also called a package. And we are going to call this pets. And in the pets package let's create a new go file called dog. Now in our dog file we are going to create a type. A type of dog and it will be a struct. Now to this we're going to add some elements. So we will put a name. Our dog needs a name. Our dog will have a color and our dog will have a breed. Now let's add our first function onto this dog. So the…
内容
-
-
-
-
(已锁定)
Structs as classes2 分钟 21 秒
-
(已锁定)
Creating a struct5 分钟 16 秒
-
(已锁定)
Encapsulation2 分钟 43 秒
-
(已锁定)
Leveraging encapsulation5 分钟 35 秒
-
(已锁定)
Solution: Struct as class2 分钟 2 秒
-
(已锁定)
Composition1 分钟 36 秒
-
(已锁定)
Leveraging composition4 分钟 11 秒
-
(已锁定)
Polymorphism2 分钟 59 秒
-
(已锁定)
Leveraging polymorphism4 分钟 49 秒
-
(已锁定)
Solution: OOP4 分钟 56 秒
-
(已锁定)
-