Files
ooplab/lab9/26.cpp
Amneesh Singh a903457fa4 lab9: reflect changes for 26 in file.org
and change typename keyword to class for convention and fix indentation

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-27 13:43:39 +05:30

29 lines
411 B
C++

#include <iostream>
using namespace std;
template <class T,
class = enable_if<is_arithmetic<T>::value, T>>
class Foo {
T x, y;
public:
Foo() {
cout << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
~Foo() { cout << "Destructor called, nothing to do here."; }
T mx() { return (x > y ? x : y); };
};
int main() {
Foo<float> bar;
cout << bar.mx() << endl;
return 0;
}