labs 9: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-26 18:06:44 +05:30
parent 4824ab9855
commit 42902fa122
6 changed files with 208 additions and 3 deletions

26
lab9/25.cpp Normal file
View File

@@ -0,0 +1,26 @@
#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;
}