Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cout;
- using std::endl;
- template<typename T>
- T max(T num) {
- return num;
- }
- template<typename T>
- T max(T num1, T num2) {
- return (num1 > num2) ? num1 : num2;
- }
- template<typename T, typename... Args>
- T max(T num1, T num2, Args... args) {
- T temp = max(num1, num2);
- return max(temp, args...);
- }
- int main() {
- double m = max(3, 4, 5, 1, 2);
- cout << m << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement