SlideShare a Scribd company logo
1 of 3
Download to read offline
Difference between C# generics and C++ templates

     S.No   C# Generics                          C++ Templates


     1      Strongly / Loosely typed:            Strongly / Loosely typed:
            C# Generic types are strong          C++ Templates are loosely typed.
            typed.

     2      Instantiated at Compile              Instantiated at Compile time /
            time / Runtime:                      Runtime:
            C# Generic types are                 C++ templates are instantiated at
            instantiated at the runtime.         the compile time.

     3      Whether it permits the type          Whether it permits the type
            parameters to have default           parameters to have default
            values ?                             values ?
            C# Generic types do not permit       C++ templates permit the type
            the type parameters to have          parameters to have default values.
            default values.

     4      Whether DLL can be created           Whether DLL can be created
            using C# Generics ?                  using C++ Templates ?
            Libraries or DLLs can be             C++ templates are always
            created using C# Generics.           expanded at compile time.
                                                 Therefore, the C++ compiler must
                                                 have access to all template types—
                                                 generally through header files—
                                                 and any types used to create the
                                                 closed types from the template
                                                 types at compile time. For this
                                                 reason alone, it is impossible to
                                                 package C++ templates into
                                                 libraries or DLLs.

                                                 The STL is a perfect example:
                                                 notice that almost every bit of your
                                                 favorite STL implementation exists
                                                 in header files.

     5      Whether it is possible to call       Whether it is possible to call
            arithmetic operators in a C#         arithmetic operators in a C++
            generic class ?                      template class ?
            C# generics do not provide the       With C++ template class, it is
            same amount of flexibility as        possible to call arithmetic
            C++ templates. For example, it       operators.
            is not possible to call arithmetic
            operators in a C# generic
            class, although it is possible to
            call user defined operators.

     6      Whether explicit                     Whether explicit specialization is
specialization is supported           supported by C++ templates ?
     by C# generics ?                       C++ template support explicit
     C# generics does not support          specialization.
     explicit specialization; that is, a
     custom implementation of a
     template for a specific type.

7    Whether partial                       Whether partial specialization is
     specialization is supported           supported by C++ templates ?
     by C# generics ?                      C++ template support partial
     C# generics does not support          specialization.
     partial specialization: a custom
     implementation for a subset of
     the type arguments.

8    Whether type parameter can            Whether type parameter can be
     be used as the base class             used as the base class for the
     for the generic type ?                template type ?
     C# does not allow the type            C++ allows the type parameter to
     parameter to be used as the           be used as the base class for the
     base class for the generic type.      template type.

9    Whether generic type                  Whether template type
     parameter can itself be a             parameter can itself be a
     generic ?                             template?
     In C#, a generic type                 C++ does allow template
     parameter cannot itself be a          parameters.
     generic, although constructed
     types can be used as generics.

10   What type of code it allows ?         What type of code it allows ?
     C# requires code in a class to        C++ allows code that might not be
     be written in such a way that it      valid for all type parameters in the
     will work with any type that          template, which is then checked for
     satisfies the constraints.C#          the specific type used as the type
     disallows as allowed in C++           parameter.
     (Please look at example from          For example, in C++ it is possible
     R.H.S column); the only               to write a function that uses the
     language constructs allowed           arithmetic operators + and - on
     are those that can be deduced         objects of the type parameter,
     from the constraints.                 which will produce an error at the
                                           time of instantiation of the template
                                           with a type that does not support
                                           these operators.

11   Which language supports               Which language supports
     generics?                             templates ?
     Generics can be supported by          Templates are a C++ only
     any .NET language that wishes         language feature.
     to do so.

12   Whether it allows non-                Whether it allows non-template
template parameters ?             parameters ?
              C# does not allow non-type       C++ allows non-type template
             template parameters.              parameters.




References:
http://webdesignpluscode.blogspot.in/2012/07/compare-c-net-generics-and-c-
templates.html

http://my.safaribooksonline.com/book/programming/csharp/9781430225379/generics/differ
ence_between_generics_and_c_plus_p

http://stackoverflow.com/questions/63694/creating-a-math-library-using-generics-in-c-
sharp

http://msdn.microsoft.com/en-us/library/c6cyy67b%28v=vs.80%29.aspx

http://www.codeguru.com/csharp/.net/cpp_managed/windowsservices/article.php/c7423/C
omparing-NET-Generics-and-C-Templates.htm


And, further updates on difference between questions and answers, please visit my
blog @ http://onlydifferencefaqs.blogspot.in/

More Related Content

What's hot (20)

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Rational rose tutorial
Rational rose tutorialRational rose tutorial
Rational rose tutorial
 
introduction to C programming (C)
introduction to C programming (C)introduction to C programming (C)
introduction to C programming (C)
 
Numba
NumbaNumba
Numba
 
Introduction to Python - Training for Kids
Introduction to Python - Training for KidsIntroduction to Python - Training for Kids
Introduction to Python - Training for Kids
 
C sharp
C sharpC sharp
C sharp
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptx
 
Python programming introduction
Python programming introductionPython programming introduction
Python programming introduction
 
Game Development With Python and Pygame
Game Development With Python and PygameGame Development With Python and Pygame
Game Development With Python and Pygame
 
Learning Python with PyCharm EDU
Learning Python with PyCharm EDU Learning Python with PyCharm EDU
Learning Python with PyCharm EDU
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Methods in java
Methods in javaMethods in java
Methods in java
 
PROJECT MANAGEMENT - (2016) SEM-VI - PRACTICAL (SLIP) QUESTIONS
PROJECT MANAGEMENT - (2016) SEM-VI - PRACTICAL (SLIP) QUESTIONSPROJECT MANAGEMENT - (2016) SEM-VI - PRACTICAL (SLIP) QUESTIONS
PROJECT MANAGEMENT - (2016) SEM-VI - PRACTICAL (SLIP) QUESTIONS
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Dependency injection
Dependency injectionDependency injection
Dependency injection
 
Python-Inheritance.pptx
Python-Inheritance.pptxPython-Inheritance.pptx
Python-Inheritance.pptx
 
Structure
StructureStructure
Structure
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
Wpf Introduction
Wpf IntroductionWpf Introduction
Wpf Introduction
 

Viewers also liked

Data structures and algorithms lab3
Data structures and algorithms lab3Data structures and algorithms lab3
Data structures and algorithms lab3Bianca Teşilă
 
Data structures and algorithms lab8
Data structures and algorithms lab8Data structures and algorithms lab8
Data structures and algorithms lab8Bianca Teşilă
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2Bianca Teşilă
 
Data structures and algorithms lab11
Data structures and algorithms lab11Data structures and algorithms lab11
Data structures and algorithms lab11Bianca Teşilă
 
Data structures and algorithms lab1
Data structures and algorithms lab1Data structures and algorithms lab1
Data structures and algorithms lab1Bianca Teşilă
 
Introduction to computer architecture and organization
Introduction to computer architecture and organizationIntroduction to computer architecture and organization
Introduction to computer architecture and organizationMuhammad Ishaq
 
Data structures and algorithms lab5
Data structures and algorithms lab5Data structures and algorithms lab5
Data structures and algorithms lab5Bianca Teşilă
 
Chapter 1 introduction to computers
Chapter 1   introduction to computersChapter 1   introduction to computers
Chapter 1 introduction to computershaider ali
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course IntroductionIntro C# Book
 

Viewers also liked (13)

Data structures and algorithms lab3
Data structures and algorithms lab3Data structures and algorithms lab3
Data structures and algorithms lab3
 
Data structures and algorithms lab8
Data structures and algorithms lab8Data structures and algorithms lab8
Data structures and algorithms lab8
 
Data structures and algorithms lab2
Data structures and algorithms lab2Data structures and algorithms lab2
Data structures and algorithms lab2
 
Data structures and algorithms lab11
Data structures and algorithms lab11Data structures and algorithms lab11
Data structures and algorithms lab11
 
Data structures and algorithms lab1
Data structures and algorithms lab1Data structures and algorithms lab1
Data structures and algorithms lab1
 
Introduction to computer architecture and organization
Introduction to computer architecture and organizationIntroduction to computer architecture and organization
Introduction to computer architecture and organization
 
Data structures and algorithms lab5
Data structures and algorithms lab5Data structures and algorithms lab5
Data structures and algorithms lab5
 
USMLE and Canadian Exams
USMLE and Canadian ExamsUSMLE and Canadian Exams
USMLE and Canadian Exams
 
Chapter 1 introduction to computers
Chapter 1   introduction to computersChapter 1   introduction to computers
Chapter 1 introduction to computers
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
0. Course Introduction
0. Course Introduction0. Course Introduction
0. Course Introduction
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
DSA-2012-Lect00
DSA-2012-Lect00DSA-2012-Lect00
DSA-2012-Lect00
 

Similar to Difference between c# generics and c++ templates

Similar to Difference between c# generics and c++ templates (20)

Migrating From Cpp To C Sharp
Migrating From Cpp To C SharpMigrating From Cpp To C Sharp
Migrating From Cpp To C Sharp
 
C# chap 1
C# chap 1C# chap 1
C# chap 1
 
C++ c#
C++ c#C++ c#
C++ c#
 
Oops index
Oops indexOops index
Oops index
 
C sharp chap1
C sharp chap1C sharp chap1
C sharp chap1
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
Tutorial csharp
Tutorial csharpTutorial csharp
Tutorial csharp
 
java vs C#
java vs C#java vs C#
java vs C#
 
C#.NET
C#.NETC#.NET
C#.NET
 
CSharp difference faqs- 1
CSharp difference faqs- 1CSharp difference faqs- 1
CSharp difference faqs- 1
 
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
21UCAC61 C# and .Net Programming.pdf(MTNC)(BCA)
 
Event Driven Programming in C#.docx
Event Driven Programming in C#.docxEvent Driven Programming in C#.docx
Event Driven Programming in C#.docx
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
Introduction of C++ By Pawan Thakur
Introduction of C++ By Pawan ThakurIntroduction of C++ By Pawan Thakur
Introduction of C++ By Pawan Thakur
 
C-sharping.docx
C-sharping.docxC-sharping.docx
C-sharping.docx
 
C#_01_CLROverview.ppt
C#_01_CLROverview.pptC#_01_CLROverview.ppt
C#_01_CLROverview.ppt
 
Difference between java and c#
Difference between java and c#Difference between java and c#
Difference between java and c#
 
Csharp
CsharpCsharp
Csharp
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
 
C#
C#C#
C#
 

More from Umar Ali

Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web apiUmar Ali
 
Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()Umar Ali
 
Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Umar Ali
 
Difference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvcDifference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvcUmar Ali
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcUmar Ali
 
ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1Umar Ali
 
Link checkers 1
Link checkers 1Link checkers 1
Link checkers 1Umar Ali
 
Affiliate Networks Sites-1
Affiliate Networks Sites-1Affiliate Networks Sites-1
Affiliate Networks Sites-1Umar Ali
 
Technical Video Training Sites- 1
Technical Video Training Sites- 1Technical Video Training Sites- 1
Technical Video Training Sites- 1Umar Ali
 
US News Sites- 1
US News Sites- 1 US News Sites- 1
US News Sites- 1 Umar Ali
 
How to create user friendly file hosting link sites
How to create user friendly file hosting link sitesHow to create user friendly file hosting link sites
How to create user friendly file hosting link sitesUmar Ali
 
Weak hadiths in tamil
Weak hadiths in tamilWeak hadiths in tamil
Weak hadiths in tamilUmar Ali
 
Bulughul Maram in tamil
Bulughul Maram in tamilBulughul Maram in tamil
Bulughul Maram in tamilUmar Ali
 
Asp.net website usage and job trends
Asp.net website usage and job trendsAsp.net website usage and job trends
Asp.net website usage and job trendsUmar Ali
 
Indian news sites- 1
Indian news sites- 1 Indian news sites- 1
Indian news sites- 1 Umar Ali
 
Photo sharing sites- 1
Photo sharing sites- 1 Photo sharing sites- 1
Photo sharing sites- 1 Umar Ali
 
File hosting search engines
File hosting search enginesFile hosting search engines
File hosting search enginesUmar Ali
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1Umar Ali
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1Umar Ali
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1Umar Ali
 

More from Umar Ali (20)

Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
 
Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()
 
Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4
 
Difference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvcDifference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvc
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
 
ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1
 
Link checkers 1
Link checkers 1Link checkers 1
Link checkers 1
 
Affiliate Networks Sites-1
Affiliate Networks Sites-1Affiliate Networks Sites-1
Affiliate Networks Sites-1
 
Technical Video Training Sites- 1
Technical Video Training Sites- 1Technical Video Training Sites- 1
Technical Video Training Sites- 1
 
US News Sites- 1
US News Sites- 1 US News Sites- 1
US News Sites- 1
 
How to create user friendly file hosting link sites
How to create user friendly file hosting link sitesHow to create user friendly file hosting link sites
How to create user friendly file hosting link sites
 
Weak hadiths in tamil
Weak hadiths in tamilWeak hadiths in tamil
Weak hadiths in tamil
 
Bulughul Maram in tamil
Bulughul Maram in tamilBulughul Maram in tamil
Bulughul Maram in tamil
 
Asp.net website usage and job trends
Asp.net website usage and job trendsAsp.net website usage and job trends
Asp.net website usage and job trends
 
Indian news sites- 1
Indian news sites- 1 Indian news sites- 1
Indian news sites- 1
 
Photo sharing sites- 1
Photo sharing sites- 1 Photo sharing sites- 1
Photo sharing sites- 1
 
File hosting search engines
File hosting search enginesFile hosting search engines
File hosting search engines
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Difference between c# generics and c++ templates

  • 1. Difference between C# generics and C++ templates S.No C# Generics C++ Templates 1 Strongly / Loosely typed: Strongly / Loosely typed: C# Generic types are strong C++ Templates are loosely typed. typed. 2 Instantiated at Compile Instantiated at Compile time / time / Runtime: Runtime: C# Generic types are C++ templates are instantiated at instantiated at the runtime. the compile time. 3 Whether it permits the type Whether it permits the type parameters to have default parameters to have default values ? values ? C# Generic types do not permit C++ templates permit the type the type parameters to have parameters to have default values. default values. 4 Whether DLL can be created Whether DLL can be created using C# Generics ? using C++ Templates ? Libraries or DLLs can be C++ templates are always created using C# Generics. expanded at compile time. Therefore, the C++ compiler must have access to all template types— generally through header files— and any types used to create the closed types from the template types at compile time. For this reason alone, it is impossible to package C++ templates into libraries or DLLs. The STL is a perfect example: notice that almost every bit of your favorite STL implementation exists in header files. 5 Whether it is possible to call Whether it is possible to call arithmetic operators in a C# arithmetic operators in a C++ generic class ? template class ? C# generics do not provide the With C++ template class, it is same amount of flexibility as possible to call arithmetic C++ templates. For example, it operators. is not possible to call arithmetic operators in a C# generic class, although it is possible to call user defined operators. 6 Whether explicit Whether explicit specialization is
  • 2. specialization is supported supported by C++ templates ? by C# generics ? C++ template support explicit C# generics does not support specialization. explicit specialization; that is, a custom implementation of a template for a specific type. 7 Whether partial Whether partial specialization is specialization is supported supported by C++ templates ? by C# generics ? C++ template support partial C# generics does not support specialization. partial specialization: a custom implementation for a subset of the type arguments. 8 Whether type parameter can Whether type parameter can be be used as the base class used as the base class for the for the generic type ? template type ? C# does not allow the type C++ allows the type parameter to parameter to be used as the be used as the base class for the base class for the generic type. template type. 9 Whether generic type Whether template type parameter can itself be a parameter can itself be a generic ? template? In C#, a generic type C++ does allow template parameter cannot itself be a parameters. generic, although constructed types can be used as generics. 10 What type of code it allows ? What type of code it allows ? C# requires code in a class to C++ allows code that might not be be written in such a way that it valid for all type parameters in the will work with any type that template, which is then checked for satisfies the constraints.C# the specific type used as the type disallows as allowed in C++ parameter. (Please look at example from For example, in C++ it is possible R.H.S column); the only to write a function that uses the language constructs allowed arithmetic operators + and - on are those that can be deduced objects of the type parameter, from the constraints. which will produce an error at the time of instantiation of the template with a type that does not support these operators. 11 Which language supports Which language supports generics? templates ? Generics can be supported by Templates are a C++ only any .NET language that wishes language feature. to do so. 12 Whether it allows non- Whether it allows non-template
  • 3. template parameters ? parameters ? C# does not allow non-type C++ allows non-type template template parameters. parameters. References: http://webdesignpluscode.blogspot.in/2012/07/compare-c-net-generics-and-c- templates.html http://my.safaribooksonline.com/book/programming/csharp/9781430225379/generics/differ ence_between_generics_and_c_plus_p http://stackoverflow.com/questions/63694/creating-a-math-library-using-generics-in-c- sharp http://msdn.microsoft.com/en-us/library/c6cyy67b%28v=vs.80%29.aspx http://www.codeguru.com/csharp/.net/cpp_managed/windowsservices/article.php/c7423/C omparing-NET-Generics-and-C-Templates.htm And, further updates on difference between questions and answers, please visit my blog @ http://onlydifferencefaqs.blogspot.in/