Constructor inheritance : Constructor « Class « Visual C++ .NET






Constructor inheritance

 
#include "stdafx.h"
using namespace System;

ref class MyBase{
    int data;
  public:
    MyBase() { Console::WriteLine("MyBase::MyBase()"); }
    MyBase(int data_in) : data(data_in) { Console::WriteLine("MyBase::MyBase(int)"); }
};

ref class Derived : MyBase
{
   public:
     Derived(int data) : MyBase(data)
     { Console::WriteLine("Derived::Derived(int)"); }

};

int main()
{
    MyBase b;
    Derived d(100);
}

   
  








Related examples in the same category

1.Adding Constructors
2.public constructor
3.Constructor order