使用模板有什么好处? [英] What are the benefits of using templates?

查看:162
本文介绍了使用模板有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我所理解的是模板功能用于处理任何类型的数据类型具有更大的灵活性。



我有什么尝试过:



尝试了解更多,但尚未

So far, what I understand is that a template function is used for having more flexibility to handle any kind of data types.

What I have tried:

Try to understand more, but yet not

推荐答案

这就是temlpates的目的,不要重复处理不同数据类型的代码。还有许多其他好处(也有缺点)。例如,请参阅Stack Overflow上发布的这个问题: C ++模板有哪些优点和缺点? - 堆栈溢出 [ ^ ]。
That's the very purpose of temlpates, don't duplicate code handling different data types. There are many other benefits (and downsides too). See, for instance, this question posted at Stack Overflow: What are the good and bad points of C++ templates? - Stack Overflow[^].


在网上搜索c ++模板优势会给你带来很多结果:

< a href =https://msdn.microsoft.com/en-us/library/z3f89ch8.aspx>模板的优点 [ ^ ]

C ++模板 - 优点和缺点 [ ^ ]

模板(C ++) - 维基百科 [ ^ ]
Searching the web for "c++ templates advantages" gives you a lot of results:
Advantages of Templates[^]
Templates in C++ - Pros and Cons[^]
Template (C++) - Wikipedia[^]


这篇关于使用模板有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆