Skip to content

Commit afb789b

Browse files
committed
Add C++ example for template function
1 parent aee543e commit afb789b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

C++/1-function.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "iostream"
2+
3+
template <typename T>
4+
T max(T x, T y) {
5+
return x < y ? y : x;
6+
}
7+
8+
int main() {
9+
int m1 = max(1, 2);
10+
std::cout << m1 << '\n';
11+
12+
double m2 = max(1.5, 2.5);
13+
std::cout << m2 << '\n';
14+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy