Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.