当前位置:网站首页>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;
}
边栏推荐
- Reading and visualization of DICOM, MHD and raw files in medical imaging
- All in one 1413: determine base
- Neural networks and deep learning Chapter 2: machine learning overview reading questions
- Observable time series data downsampling practice in Prometheus
- windows下Redis-cluster集群搭建
- 电源管理总线 (PMBus)
- 揭秘技术 Leader 必备的七大清奇脑回路
- Introduction to RT thread kernel (5) -- memory management
- Machine learning -- neural network
- Hexadecimal to decimal
猜你喜欢
Cookie learning diary 1
MacBook installation postgresql+postgis
Uncover the seven quirky brain circuits necessary for technology leaders
Components in protective circuit
2022-2028 global and Chinese video coding and transcoding Market Research Report
TPG x AIDU | AI leading talent recruitment plan in progress!
网络安全-记录web漏洞修复
Mxnet imports various libcudarts * so、 libcuda*. So not found
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
随机推荐
Live broadcast preview | container service ack elasticity prediction best practice
Decimal to hexadecimal
10 programming habits that web developers should develop
Learning MVVM notes (1)
C26451: arithmetic overflow: use the operator * on a 4-byte value, and then convert the result to an 8-byte value. To avoid overflow, cast the value to wide type before calling the operator * (io.2)
解密函数计算异步任务能力之「任务的状态及生命周期管理」
CSDN正文自动生成目录
【虛幻引擎UE】實現UE5像素流部署僅需六步操作少走彎路!(4.26和4.27原理類似)
How to get the first few pieces of data of each group gracefully
About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
What are the building energy-saving software
Qt蓝牙:搜索蓝牙设备的类——QBluetoothDeviceDiscoveryAgent
Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
Mixed compilation of C and CC
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
Hexadecimal to octal
Function (basic: parameter, return value)
All in one 1413: determine base
Function (error prone)
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)