You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
352 B
29 lines
352 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type Square struct {
|
|
width int
|
|
}
|
|
|
|
func area(s *Square) {
|
|
fmt.Printf("Area Function result: %d\n", (s.width * s.width))
|
|
}
|
|
|
|
func (s * Square) area() {
|
|
fmt.Printf("Area Method result: %d\n", (s.width * s.width))
|
|
}
|
|
|
|
func main(){
|
|
r := Square{
|
|
width:20,
|
|
}
|
|
p := &r // poniter
|
|
area(p)
|
|
p.area()
|
|
|
|
//area(r)
|
|
r.area()
|
|
} |