Skip to content

Commit

Permalink
Added another comment for templates
Browse files Browse the repository at this point in the history
  • Loading branch information
nagrat committed Mar 14, 2023
1 parent c7d0e46 commit 99d1575
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Functions/templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using namespace std;
*/

template<class T> T add(T &x, T &y) { // template to make a function to add numbers
// the T means type meaning that the values of the parameters can be any data-type
// &x, &y are references to values that can be anything -> float, int, long, double etc
T result = x + y; // makes a return variable from the T class part; can be anything
// -> is now dynamically typed as it will find itself on runtime not beforehand
Expand Down

0 comments on commit 99d1575

Please sign in to comment.