SHARE
TWEET

Untitled

a guest Jan 16th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. type person struct {
  6.     name string
  7.     age  int
  8. }
  9.  
  10. type woman struct {
  11.     person
  12.     husband string
  13.     husbandAge int
  14.     name string
  15. }
  16.  
  17. func (w *woman) getName() string {
  18.     return w.name
  19. }
  20.  
  21. func (w *woman) getPersonName() string {
  22.     return w.person.name
  23. }
  24.  
  25. func (p *person) getName() string {
  26.     return p.name
  27. }
  28.  
  29. func main() {
  30.     w := woman{}
  31.     w.age = 25
  32.     w.husband = "Ivan"
  33.     w.husbandAge = 26
  34.     w.person.name = "Tania"
  35.     w.name = "Yulia"
  36.  
  37.  
  38.     fmt.Println(w.name)
  39.     fmt.Println(w.person.name)
  40.     fmt.Println("test function")
  41.     fmt.Println(w.getName())
  42.     fmt.Println(w.getPersonName())
  43.     fmt.Println(w.person.getName())
  44.  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top