template.cpp
来自「这些源代码」· C++ 代码 · 共 20 行
CPP
20 行
/*
template.cpp - A program to test trivial templates.
*/
#include <stdio.h>
template <class T> T Half (T x);;
int main ()
{
printf ("Return for int is %f\n", (float) Half (7));
printf ("Return for long is %f\n", (float) Half (7L));
printf ("Return for double is %f\n", Half (7.0));
return (0);
}
template <class T> T Half (T x)
{
return (x / 2);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?