Illegal cloning with MemberwiseClone. | Lecture 8 - slide 31 : 37 Program 4 |
using System; public class Application{ public static void Main(){ Point p1 = new Point(1.1, 2.2), p2, p3; p2 = (Point)p1.MemberwiseClone(); // Compile-time error. // Cannot access protected member 'object.MemberwiseClone()' // via a qualifier of type 'Point' p3 = p1.move(3.3, 4.4); Console.WriteLine("{0} {1} {2}", p1, p2, p3); } } |