Files
ooplab/lab9/25.cpp
Amneesh Singh 42902fa122 labs 9: init
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
2022-12-26 18:06:44 +05:30

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;
}