Last active
April 26, 2019 10:23
-
-
Save kateolenya/e7f824b89ff2d013d3e6b9d4c726e1eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <class T> | |
void custom_add (T a, T b) { | |
cout << "Template result = " << a + b << endl; | |
} | |
int main () { | |
int p = 1; | |
int i = 2; | |
float n = 10.1; | |
float e = 11.2; | |
custom_add<int>(p, i); // type specifier <int> present | |
custom_add(n, e); // no type specifier here | |
// custom_add(p, e); // this call will cause compile-time error | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment