#include "stdafx.h"
using namespace System;
generic <typename T>
ref class GenericClass
{
T t;
public:
GenericClass() {}
property T InnerValue
{
T get() { return t; }
void set(T value) { t = value; }
}
};
int main()
{
double d = 0.01;
int n = 12;
GenericClass<double>^ r_double = gcnew GenericClass<double>();
GenericClass<int>^ r_int = gcnew GenericClass<int>();
r_double->InnerValue = d;
r_int->InnerValue = n;
Console::WriteLine( r_double->InnerValue );
Console::WriteLine( r_int->InnerValue );
}
|