当前位置:网站首页>Function template
Function template
2022-07-05 04:33:00 【On the bald Road】
Apply to The body of the function is the same , The number of function parameters is the same , And different types of situations ; Pay attention to the difference between heavy load and heavy load .
How to write it :template<typename T>
General function definition
example :
#include<iostream>
using namespace std;
template<typename T>
T max1(T a, T b) {
if (a > b)
b = a;
return b;
}
int main() {
int a = max1(5, 4);
cout << a << endl;
double b = max1(5.44, 6.31);
cout << b;
return 0;
}
边栏推荐
- 包 类 包的作用域
- Sword finger offer 04 Search in two-dimensional array
- QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
- 美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
- Leetcode 222 number of nodes of complete binary tree
- WeNet:面向工业落地的E2E语音识别工具
- Decryption function calculates "task state and lifecycle management" of asynchronous task capability
- 学习MVVM笔记(一)
- User behavior collection platform
- Serpentine matrix
猜你喜欢
Mxnet imports various libcudarts * so、 libcuda*. So not found
网络安全-记录web漏洞修复
How should programmers learn mathematics
自动语音识别(ASR)研究综述
【虚幻引擎UE】运行和启动的区别,常见问题分析
假设检验——《概率论与数理统计》第八章学习笔记
概率论与数理统计考试重点复习路线
Serpentine matrix
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
【thingsboard】替换首页logo的方法
随机推荐
Cookie learning diary 1
Data security -- 14 -- Analysis of privacy protection governance
Seven join join queries of MySQL
A solution to the problem that variables cannot change dynamically when debugging in keil5
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
[phantom engine UE] package error appears! Solutions to findpin errors
PHP读取ini文件并修改内容写入
How should programmers learn mathematics
2022-2028 global and Chinese virtual data storage Market Research Report
[crampon programming] lintcode decoding Encyclopedia - 1100 strange printer
mxnet导入报各种libcudart*.so、 libcuda*.so找不到
A應用喚醒B應該快速方法
Matplotlib draws three-dimensional scatter and surface graphs
【UNIAPP】系统热更新实现思路
自动语音识别(ASR)研究综述
机器学习 --- 决策树
Sword finger offer 04 Search in two-dimensional array
MacBook installation postgresql+postgis
How can CIOs use business analysis to build business value?
Network security - record web vulnerability fixes