浙林龙哥

   :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

原来函数模板可以对托管使用的(对类不行,编译器报告不能对模板类使用托管):
template <typename T>
String * F(T* a)
{
 return a->ConnectionString;
}

int _tmain()
{
    // TODO: 请用您自己的代码替换下面的示例代码。
 String* connectionString = S"Server=localhost;DataBase=;Integrated Security=SSPI";
 SqlConnection* m = new SqlConnection(connectionString);

 Console::WriteLine(F(m));
 Console::Read();
 return 0;
}

posted on 2004-11-26 15:40  浙林龙哥  阅读(1183)  评论(2编辑  收藏  举报