Extends abstract class
#include "stdafx.h" using namespace System; ref class AbstractBaseClass abstract{ protected: int AbstractVar; AbstractBaseClass(int val): AbstractVar(val) {} public: virtual void Method1() = 0; // unimplemented method virtual void Method2() = 0; void Method3() { Console::WriteLine(AbstractVar.ToString()); } }; ref class MidAbstractBaseClass abstract : public AbstractBaseClass { public: virtual void Method1() override sealed { Console::WriteLine((AbstractVar * 3).ToString()); } protected: MidAbstractBaseClass(int val) : AbstractBaseClass(val) {} }; ref class DerivedExClass : public MidAbstractBaseClass { public: DerivedExClass(int val) : MidAbstractBaseClass(val) {} virtual void Method2() override { Console::WriteLine((AbstractVar * 2).ToString()); } }; void testMethod(AbstractBaseClass ^aec) { aec->Method1(); aec->Method2(); aec->Method3(); } void main() { AbstractBaseClass ^Ab1 = gcnew DerivedExClass(5); Ab1->Method1(); Ab1->Method2(); Ab1->Method3(); AbstractBaseClass ^Ab2 = gcnew DerivedExClass(6); testMethod(Ab2); DerivedExClass ^dc = gcnew DerivedExClass(7); testMethod(dc); }