Created
November 19, 2012 16:14
-
-
Save Jack2/4111542 to your computer and use it in GitHub Desktop.
[C++]template_example
This file contains hidden or 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 <typename T> | |
T Add(T a, T b) | |
{ | |
return a+b; | |
} | |
int main() | |
{ | |
cout << Add(1,1) << endl; | |
cout << Add(2.2, 2.2) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment