#include "stdafx.h"
using namespace System;
public ref class MyClass
{
public:
MyClass(String^ name, int age)
{
Name = name;
Age = age;
}
MyClass(MyClass% myClass)
{
*this = myClass;
}
virtual String^ ToString() override
{
return String::Format("{0}'s Age is {1}", Name, Age);
}
void operator = (MyClass% myClass)
{
Name = myClass.Name;
Age = myClass.Age;
}
private:
String^ Name;
int Age;
};
void myFunc(MyClass param)
{
Console::WriteLine(%param);
}
void main()
{
MyClass myClass1("M", 30);
MyClass myClass2("V", 8);
myFunc(myClass1);
myClass1 = myClass2;
Console::WriteLine(%myClass1);
MyClass^ myClass3 = %myClass2;
MyClass myClass4 = *myClass3;
MyClass% myClass5 = myClass4;
}