/* * ===================================================================================== * * Filename: funtemp.cpp * * Description: none * * Version: 1.0 * Created: 2010/1/17 13:32:28 * Revision: none * Compiler: gcc * * Author: bird * Company: nbut * * ===================================================================================== */ #include <iostream> #include <stdlib.h> using namespace std; template<class t> t fun(t a){ return a*2; } int main ( int argc, char *argv[] ) { cout<<fun(8)<<endl; cout<<fun(7.7)<<endl; return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
> volumn one chapter 16
最新推荐文章于 2024-07-25 21:26:31 发布
本文介绍了一个简单的C++模板函数示例,该函数接受一个参数并返回其两倍的值。演示了如何使用此模板函数处理不同类型的数据,如整数和浮点数。

83

被折叠的 条评论
为什么被折叠?



