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:
13
lab9/26.cpp
13
lab9/26.cpp
@@ -1,15 +1,13 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template <typename T,
|
template <class T,
|
||||||
typename = enable_if<is_arithmetic<T>::value, T>>
|
class = enable_if<is_arithmetic<T>::value, T>>
|
||||||
class Foo
|
class Foo {
|
||||||
{
|
|
||||||
T x, y;
|
T x, y;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Foo()
|
Foo() {
|
||||||
{
|
|
||||||
cout << "x: ";
|
cout << "x: ";
|
||||||
cin >> x;
|
cin >> x;
|
||||||
cout << "y: ";
|
cout << "y: ";
|
||||||
@@ -21,8 +19,7 @@ public:
|
|||||||
T mx() { return (x > y ? x : y); };
|
T mx() { return (x > y ? x : y); };
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main() {
|
||||||
{
|
|
||||||
Foo<float> bar;
|
Foo<float> bar;
|
||||||
|
|
||||||
cout << bar.mx() << endl;
|
cout << bar.mx() << endl;
|
||||||
|
@@ -45,8 +45,8 @@ y: 9.1
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template <typename T,
|
template <class T,
|
||||||
typename = std::enable_if_t<std::is_arithmetic<T>::value, T>>
|
class = enable_if<is_arithmetic<T>::value, T>>
|
||||||
class Foo {
|
class Foo {
|
||||||
T x, y;
|
T x, y;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user