Skip to content

Instantly share code, notes, and snippets.

@kateolenya
Last active April 26, 2019 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateolenya/e7f824b89ff2d013d3e6b9d4c726e1eb to your computer and use it in GitHub Desktop.
Save kateolenya/e7f824b89ff2d013d3e6b9d4c726e1eb to your computer and use it in GitHub Desktop.
#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