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

28
lab9/26.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <iostream>
using namespace std;
template <typename T,
typename = std::enable_if_t<std::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;
}