376 Object-Oriented Programming: Inheritance Chapter 9 Circle5object being (Database web hosting)
376 Object-Oriented Programming: Inheritance Chapter 9 Circle5object being constructed, Circle5 s ToStringmethod executes even when ToString is invoked from the body of class Point4 s constructor. [Note: This would not be the case if the Point4constructor were called to initialize a an object that was actually a new Point4 object.] When the Point4 constructor invokes method ToString for the Circle5 being constructed, the program displays 0 for the radius value, because the Circle5 constructor s body has not yet initialized the radius. Remember that 0 is the default value of a double variable. The second line of output shows the proper radiusvalue (4.5), because that line is output after the radiusis initialized. 1 // Fig. 9.19: ConstructorAndDestructor.cs 2 // Display order in which base-class and derived-class constructors 3 // and destructors are called. 4 5 using System; 6 7 // ConstructorAndFinalizer class definition 8 class ConstructorAndFinalizer 9 { 10 // main entry point for application. 11 static void Main( string[] args ) 12 { 13 Circle5 circle1, circle2; 14 15 // instantiate objects 16 circle1 = new Circle5( 72, 29, 4.5 ); 17 circle2 = new Circle5( 5, 5, 10 ); 18 19 Console.WriteLine(); 20 21 // mark objects for garbage collection 22 circle1 = null; 23 circle2 = null; 24 25 // inform garbage collector to execute 26 System.GC.Collect(); 27 28 } // end method Main 29 30 } // end class ConstructorAndDestructor Point4 constructor: Center = [72, 29]; Radius = 0 Circle5 constructor: Center = [72, 29]; Radius = 4.5 Point4 constructor: Center = [5, 5]; Radius = 0 Circle5 constructor: Center = [5, 5]; Radius = 10 Circle5 destructor: Center = [5, 5]; Radius = 10 Point4 destructor: Center = [5, 5]; Radius = 10 Circle5 destructor: Center = [72, 29]; Radius = 4.5 Point4 destructor: Center = [72, 29]; Radius = 4.5 Fig. 9.19 Fig. 9.19Fig. 9.FiFi19g. 9.19g.9.19Order in which constructors and destructors are called.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.