public constructor : Constructor « Class « Visual C++ .NET






public constructor

 
#include "stdafx.h"
using namespace System;

ref class MyClass
{
   public:

   literal String^ name = "Bob";

   MyClass()
   {
       Console::WriteLine(name);
   }

   void Print()
   {
       Console::WriteLine(name);
   }
};

int main()
{
   MyClass^ c = gcnew MyClass();
   c->Print();

   Console::WriteLine( MyClass::name );
}

   
  








Related examples in the same category

1.Adding Constructors
2.Constructor inheritance
3.Constructor order