当前位置:网站首页>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;
}
边栏推荐
- Serpentine matrix
- TPG x AIDU | AI leading talent recruitment plan in progress!
- 美国5G Open RAN再遭重大挫败,抗衡中国5G技术的图谋已告失败
- Stage experience
- 包 类 包的作用域
- Discussion on the dimension of confrontation subspace
- Reading and visualization of DICOM, MHD and raw files in medical imaging
- Matplotlib draws three-dimensional scatter and surface graphs
- Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
- Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
猜你喜欢
[phantom engine UE] package error appears! Solutions to findpin errors
Managed service network: application architecture evolution in the cloud native Era
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
MacBook安装postgreSQL+postgis
Fonction (sujette aux erreurs)
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
线上故障突突突?如何紧急诊断、排查与恢复
自动语音识别(ASR)研究综述
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
随机推荐
【虚幻引擎UE】运行和启动的区别,常见问题分析
Key review route of probability theory and mathematical statistics examination
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
取余操作是一个哈希函数
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
函數(易錯)
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
Live broadcast preview | container service ack elasticity prediction best practice
概率论与数理统计考试重点复习路线
程序员应该怎么学数学
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
指针函数(基础)
Decimal to hexadecimal
English topic assignment (27)
防护电路中的元器件
[thingsboard] how to replace the homepage logo
Here comes the Lantern Festival red envelope!
Machine learning -- neural network