-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicFunctionTemplate.cpp
More file actions
32 lines (27 loc) · 980 Bytes
/
BasicFunctionTemplate.cpp
File metadata and controls
32 lines (27 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* =====================================================================================
*
* Filename: BasicFunctionTemplate.cpp
*
* Description: Basic function Template
*
* Created: 26/07/2020
*
* Author: Maikol Guzmán mikeguzman@gmail.com
* Organization: Universidad Nacional de Costa Rica
*
* =====================================================================================
*/
#include <iostream> // allows program to output data to the screen
template<typename T>
auto add(const T &lhs, const T &rhs) {
return lhs + rhs;
}
// function main begins program execution
int main(int argc, const char *argv[]) {
std::cout << "Welcome to the UNA!" << std::endl; // display message
std::cout << add(5,8) << '\n'; // print 13
std::cout << add(1.2,1.5) << '\n'; // print 2.7
// std::cout << add(5,1.1) << '\n'; // error why?
return 0; // indicate that program ended successfully
} // end function main