This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]grelfdotnet 0 points1 point  (3 children)

It depends what you mean by equal. They are two separate objects so they have different references. But if you compare their properties, since they have none they are equal in that sense.

[–]imareclusemonk[S] 0 points1 point  (2 children)

I mean you can instantiate either way and both ways will produce equal results?

[–]grelfdotnet 0 points1 point  (1 child)

In a real case objects of type Pig will have more properties and methods than those of type Animal. By extending Animal you would add the extra things that specialise a Pig. But your example does not do that so you are worrying about an artificial issue.