Skip to content

Instantly share code, notes, and snippets.

@arrbxr
Last active May 12, 2020 18:01
Show Gist options
  • Save arrbxr/c294fb2349eb26dab5cc787001a89bbc to your computer and use it in GitHub Desktop.
Save arrbxr/c294fb2349eb26dab5cc787001a89bbc to your computer and use it in GitHub Desktop.
#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