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 trialbabasariffodeen
6,475 Points"We need to tell it to call the Point class constructor, and pass these parameters"... Why?
I do not get why we must add :base(x,y) if we've already created the MapLocation constructor with two parameters of int x and y.
It's more confusing to me because the task that comes up after regarding the polygon and square bares little resemblance to the video in terms of the base constructor parameters.
Any help would be appreciated!
class MapLocation : Point
{
public MapLocation(int x, int y) : base(x, y) //I don't get this bit!!!
{
}
}
Note: This link of this lesson from which I am confused is: https://teamtreehouse.com/library/c-objects/inheritance/inheritance-in-code
1 Answer
Steven Parker
231,236 PointsIf you don't specify an alternative base constructor, it will use the default.
In this case, the base constructor that takes two parameters is desired intead of using the default (which would take no parameters).