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 trialRaiyan Rahman
Courses Plus Student 8,091 PointsUnable to compile program.
Hello Everyone, I've been attempting to compile my Game program as described in the 2nd inheritance video but I'm encountering the following error when I try to compile the program:
"treehouse:~/workspace$ mcs -out:TreehouseDefense.exe *.cs
Game.cs(15,17): warning CS0219: The variable p' is assigned but its value is never used
Point.cs(24,31): error CS0120: An object reference is required to access non-static member
Treeh
ouseDefense.Point.X'"
Does anyone know what could be causing this?
I've taken a snapshot of my workspace so that you can reproduce the bug:
Thanks in advance.
1 Answer
Steven Parker
231,271 PointsYou have a warning, and a typo:
This line in Game.cs was used in the video to demonstrate assignment of inherited types, but it was removed later. Even if left in, it does not cause an error, only a warning:
Point p = x;
In Point.cs on this line:
return DistanceTo(Point.X, point.Y);
You have written "Point.X
" with a capital "P", but it should be "point.X
".
Raiyan Rahman
Courses Plus Student 8,091 PointsRaiyan Rahman
Courses Plus Student 8,091 PointsThanks for your help Steven, that cleared everything up.