// Class.cpp : main project file.

#include "stdafx.h"
using namespace System;

ref class MyClass {
public:
   int i;

   // nested class
   ref class MyClass2 {
   public:
      int i;
   };

   // nested interface
   interface struct MyInterface {
      void f();
   };
};

ref class MyClass2 : public MyClass::MyInterface {
public:
   virtual void f() {
      Console::WriteLine("Testing MyClass2...");
   }
};

public value struct MyStruct {
   void f() {
      Console::WriteLine("Testing MyStruct...");
   }   
};

int main() {
   // instantiate ref type on garbage-collected heap
   MyClass ^ p_MyClass = gcnew MyClass;
   p_MyClass -> i = 4;

   Console::WriteLine("p_MyClass -> i = {0}", p_MyClass -> i);

   // instantiate value type on garbage-collected heap
   MyStruct ^ p_MyStruct = gcnew MyStruct;
   p_MyStruct -> f();

   // instantiate value type on the stack
   MyStruct p_MyStruct2;
   p_MyStruct2.f();

   // instantiate nested ref type on garbage-collected heap
   MyClass::MyClass2 ^ p_MyClass2 = gcnew MyClass::MyClass2;
   p_MyClass2 -> i = 5;

   Console::WriteLine("p_MyClass2 -> i = {0}", p_MyClass2 -> i);
}

