且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[导入]Are Generics in .NET like Templates in C++?

更新时间:2022-09-11 13:51:26


No.

While Generic types do have a similar syntax to C++ templates, they are instantiated at runtime as opposed to compile time, and they can be reflected on via meta-data.  Also, in Generics, member access on the type paramater is verified based on the constraints placed on the type parameter; whereas, in templates, member access is verified on the type argument after instantiation.

Brandon Bray (Program Manager for the Visual C++ Compiler front-end at Microsoft) has a blog entry where he draws out the distinctions between Generics and Template.

Starting with VS 2005, C#, Managed C++, and VB will have CLR support for generics.  Read these two MSDN Magazine articles for more details. Introducing Generics in the CLR & More on Generics in the CLR

[Author: SantoshZ]

[导入]Are Generics in .NET like Templates in C++?




本文转自斯克迪亚博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2004/09/22/45403.html,如需转载请自行联系原作者