Skip to content

Instantly share code, notes, and snippets.

@jitpaul

jitpaul/Intro0 Secret

Created May 4, 2018 06:08
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 jitpaul/afc215d1a322bf7e5d68fe6c3e44a891 to your computer and use it in GitHub Desktop.
Save jitpaul/afc215d1a322bf7e5d68fe6c3e44a891 to your computer and use it in GitHub Desktop.
Templates
/* Template Function. 'template <class T>' or 'template <typename T>'
can be used here.*/
template <class T>
void exampleFunction(T val) {
}
/* Template Class. 'template <class T>' or 'template <typename T>'
can be used here.*/
template <class T>
class ExampleClass {
};
int main() {
exampleFunction<int>(5); //Here 'int' is a template argument and '5' is a function argument
ExampleClass<int> ec1;//Here 'int' is a template argument
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment