Created
March 11, 2022 02:09
-
-
Save didi1246888/eb4278e5a7857d94124b534eaa03b26a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Person struct { // abstract field | |
name string | |
} | |
func (p *Person) getName() { // Encapsulation method | |
fmt.Println(p.name) | |
} | |
type Inherit struct { // inheritance | |
Person | |
} | |
func main() { | |
i := Inherit{Person{"night guard"}} | |
i.getName() // output night guard | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment