using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication7 { class Cconstructor { int A, B; public Cconstructor(int X, int Y) { A = X; B = Y; } //Copy Constructor public Cconstructor(Cconstructor T) { A = T.A; B = T.B; } public void Print() { Console.WriteLine("A = {0}\tB = {1}", A, B); } } class CopyConstructor { static void Main() { Cconstructor T2 = new Cconstructor(80, 90); //Invoking copy constructor Cconstructor T3 = new Cconstructor(T2); T2.Print(); T3.Print(); Console.Read(); } } }
Output :
Tags:
csharp.net