Last active
May 12, 2020 18:01
-
-
Save arrbxr/c294fb2349eb26dab5cc787001a89bbc to your computer and use it in GitHub Desktop.
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
#include<iostream> | |
using namespace std; | |
template <class T> | |
class myvalues { | |
T myval1, myval2; // two value of type T | |
public: | |
myvalues(T arg1, T arg2){ | |
myval1 = arg1; | |
myval2 = arg2; | |
} | |
T max(); | |
} | |
template <class T> | |
T myvalues<T>::max() //definition of a function with type T | |
{ | |
if(myval1 > myval2){ | |
return myval1; | |
}else{ | |
return myval2; | |
} | |
} | |
int main () { | |
myvalues <int> obj(20, 50); //try changing the value and value types to results for different types | |
cout << "Max value is: " << obj.max(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment