and change typename keyword to class for convention and fix indentation Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
29 lines
411 B
C++
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;
|
|
}
|