#include "stdafx.h"
using namespace System;
ref struct R
{
R()
{
val = 1;
}
// copy constructor
R( R% r)
{
val = r.val;
}
property int val;
};
void f(R r_local)
{
r_local.val = 2;
Console::WriteLine("Within f: " + r_local.val);
}
int main()
{
R r;
f(r);
Console::WriteLine("Outside f: " + r.val);
R^ rhat = gcnew R();
f(*rhat);
Console::WriteLine("Outside f: " + rhat->val);
}