#include "stdafx.h"
using namespace System;
ref class ParentClass{
public:
ParentClass() : PVal(10) {}
ParentClass(int inVal) : PVal(inVal) {}
ParentClass(const ParentClass %p) : PVal(p.PVal) {}
int PVal;
};
ref class ChildClass : public ParentClass{
public:
ChildClass () : CVal(20) {}; // default constructor
ChildClass (int inVal1, int inVal2) : ParentClass(inVal1), CVal(inVal2) {}
ChildClass(const ChildClass %vals) : ParentClass(vals.PVal), CVal(vals.CVal) {}
int CVal;
};
void main()
{
ParentClass p1(4);
ParentClass p2 = p1; // Copy Constructor
p1.PVal = 2;
Console::WriteLine("p1.PVal=[{0}] p2.PVal=[{1}]", p1.PVal, p2.PVal);
}