Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
I'm having a bit of confusion with variable declaration of type "class name"
Can someone give clarification on why he declared _location with type MapLocation? I somewhat understand why he's doing it, because he's trying to reference from the MapLocation class. But what is being referenced from it? I tried looking in the class, but could not find anything remotely close to what it is referencing?
Steven Parker215,939 Points
_location" variable is what is called a "backing store" or "backing variable". It's a private variable that holds a value that is normally accessed using a public property (in this case named "
Location"). The variable and property are both declared as the same type and work together.
In this app, they are used to store the location on the map of each "Invader" instance.