358 Object-Oriented Programming: Inheritance Chapter (Free web hosting services) 9 18 //
358 Object-Oriented Programming: Inheritance Chapter 9 18 // constructor 19 public Point2( int xValue, int yValue ) 20 { 21 // implicit call to Object constructor occurs here 22 X = xValue; 23 Y = yValue; 24 } 25 26 // property X 27 public int X 28 { 29 get 30 { 31 return x; 32 } 33 34 set 35 { 36 x = value; // no need for validation 37 } 38 39 } // end property X 40 41 // property Y 42 public int Y 43 { 44 get 45 { 46 return y; 47 } 48 49 set 50 { 51 y = value; // no need for validation 52 } 53 54 } // end property Y 55 56 // return string representation of Point2 57 public override string ToString() 58 { 59 return “[” + x + “, ” + y + “]”; 60 } 61 62 } // end class Point2 Fig. 9.9 Fig. 9.9Fig. 9.FiFi9g. 9.9g. 9.9Point2class represents an x-y coordinate pair as protecteddata. (Part 2 of 2.) Class Circle3 (Fig. 9.10) modifies class Circle2 (Fig. 9.8) to inherit from class Point2 rather than inheriting from class Point. Because class Circle3 is a class derived from class Point2, class Circle3 can access class Point2 s protected member variables x and y directly, and the compiler does not generate errors when compiling Fig. 9.10. This shows the special privileges that a derived class is granted to access
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.