#include "stdafx.h" using namespace System; generic <typename T> where T: gcnew() T CreateInstance() { return gcnew T(); } ref class MyClass { public: MyClass() { } }; int main() { int i = CreateInstance<int>(); MyClass^ r = CreateInstance<MyClass^>(); }