27 lines
344 B
C++
27 lines
344 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
template <typename T,
|
|
typename = enable_if_t<std::is_arithmetic<T>::value, T>>
|
|
class Foo {
|
|
T x, y;
|
|
|
|
public:
|
|
Foo() {
|
|
cout << "x: ";
|
|
cin >> x;
|
|
cout << "y: ";
|
|
cin >> y;
|
|
}
|
|
|
|
T sum() { return x + y; };
|
|
};
|
|
|
|
int main() {
|
|
Foo<float> bar;
|
|
|
|
cout << bar.sum();
|
|
|
|
return 0;
|
|
}
|