public abstract class BaseClass { public virtual void VirtualMethod() { Console.WriteLine("NewBaseClass:VirtualMethod"); } } public class DerivedClass : BaseClass { public override void VirtualMethod() { Console.WriteLine("NewClassA:VirtualMethod"); } }
// Create an instance of DerivedClass DerivedClass *dc = new DerivedClass(); // BTW this will work as well: //BaseClass *dc = new DerivedClass(); // Call the method of base class dc->BaseClass::VirtualMethod(); // Let' clean delete dc;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)