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

Regula Falsi (False position) Method
Regula Falsi (False position) MethodRegula Falsi (False position) Method
Regula Falsi (False position) MethodIsaac Yowetu
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud ComputingSuman Jha
 
Inductive bias
Inductive biasInductive bias
Inductive biasswapnac12
 
Migration into a Cloud
Migration into a CloudMigration into a Cloud
Migration into a CloudDivya S
 
Networking in cloud computing
Networking in cloud computingNetworking in cloud computing
Networking in cloud computingBarani Tharan
 
Cloud Computing Business Models
Cloud Computing Business ModelsCloud Computing Business Models
Cloud Computing Business ModelsMourad ZEROUKHI
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in MatlabMohamed Loey
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logicgiki67
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplicationMegha V
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations iAli mahmood
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4DigiGurukul
 
What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...Shashi soni
 

What's hot (20)

Regula Falsi (False position) Method
Regula Falsi (False position) MethodRegula Falsi (False position) Method
Regula Falsi (False position) Method
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
2 vm provisioning
2 vm provisioning2 vm provisioning
2 vm provisioning
 
Inductive bias
Inductive biasInductive bias
Inductive bias
 
Migration into a Cloud
Migration into a CloudMigration into a Cloud
Migration into a Cloud
 
Networking in cloud computing
Networking in cloud computingNetworking in cloud computing
Networking in cloud computing
 
Cloud Computing Business Models
Cloud Computing Business ModelsCloud Computing Business Models
Cloud Computing Business Models
 
Software agents
Software agentsSoftware agents
Software agents
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in Matlab
 
numerical methods
numerical methodsnumerical methods
numerical methods
 
Chapter 4 (final)
Chapter 4 (final)Chapter 4 (final)
Chapter 4 (final)
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logic
 
Strassen's matrix multiplication
Strassen's matrix multiplicationStrassen's matrix multiplication
Strassen's matrix multiplication
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations i
 
Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4Artificial Intelligence Notes Unit 4
Artificial Intelligence Notes Unit 4
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...What is Virtualization and its types & Techniques.What is hypervisor and its ...
What is Virtualization and its types & Techniques.What is hypervisor and its ...
 
AI-09 Logic in AI
AI-09 Logic in AIAI-09 Logic in AI
AI-09 Logic in AI
 
cloud storage
cloud storagecloud storage
cloud storage
 
Cloud Computing: Virtualization
Cloud Computing: VirtualizationCloud Computing: Virtualization
Cloud Computing: Virtualization
 

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

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

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/