Advertisement
cwchen

[Go][excerpt] Wrong polymorphism.

Oct 5th, 2017
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.18 KB | None | 0 0
  1. // Declare Point and Point3D as above.
  2.  
  3. func main() {
  4.     points := make([]*Point, 0)
  5.  
  6.     p1 := NewPoint(3, 4)
  7.     p2 := NewPoint3D(1, 2, 3)
  8.  
  9.     // Error!
  10.     points = append(points, p1, p2)
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement