Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Inheritance Inheritance in Code

Donnell Schroeter
Donnell Schroeter
6,692 Points

Point x = new MapLocation(4, 2);

What is the benefit of instantiating an object of type Point to a new instance of MapLocation?

1 Answer

Steven Parker
Steven Parker
229,744 Points

:point_right: There's no advantage to assigning a new MapLocation to a Point.

The result is the same as if you had assigned a new Point. I suspect this is shown in the video only as a way to illustrate the relationship between a base class and a derived class.

Ranvir Sahota
Ranvir Sahota
9,844 Points

According to this SO article http://stackoverflow.com/questions/10951982/c-sharp-declare-subclass-as-type-superclass there will be different results between the two assignments. But I don't quite understand the article I get the feeling there is difference from it. Could perhaps explain it? There is the chance you don't read this I'll post it as a new question?