lab9: reflect changes for 26 in file.org

and change typename keyword to class for convention and fix indentation

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-27 13:41:00 +05:30
parent 10350a5670
commit a903457fa4
4 changed files with 19 additions and 22 deletions

BIN
file.pdf

Binary file not shown.

BIN
lab9/26 Executable file

Binary file not shown.

View File

@@ -1,31 +1,28 @@
#include <iostream>
using namespace std;
template <typename T,
typename = enable_if<is_arithmetic<T>::value, T>>
class Foo
{
T x, y;
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 << "x: ";
cin >> x;
cout << "y: ";
cin >> y;
}
~Foo() { cout << "Destructor called, nothing to do here."; }
~Foo() { cout << "Destructor called, nothing to do here."; }
T mx() { return (x > y ? x : y); };
T mx() { return (x > y ? x : y); };
};
int main()
{
Foo<float> bar;
int main() {
Foo<float> bar;
cout << bar.mx() << endl;
cout << bar.mx() << endl;
return 0;
return 0;
}

View File

@@ -45,8 +45,8 @@ y: 9.1
#include <iostream>
using namespace std;
template <typename T,
typename = std::enable_if_t<std::is_arithmetic<T>::value, T>>
template <class T,
class = enable_if<is_arithmetic<T>::value, T>>
class Foo {
T x, y;