-
-
Save jitpaul/afc215d1a322bf7e5d68fe6c3e44a891 to your computer and use it in GitHub Desktop.
Templates
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
/* 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