- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
#include <iostream>
using namespace std;
class Boolean {
public:
Boolean() : m_flag(false), m_val(0) {}
Boolean(bool flag) : m_flag(flag), m_val(0) {}
Boolean(bool flag, int val) : m_flag(flag), m_val(val) {}
Boolean operator || (int val) {
return Boolean(m_flag || val == m_val, m_val);
}
operator bool() { return m_flag; }
private:
bool m_flag;
int m_val;
};
class Integer {
public:
Integer() : m_val(0) {}
Integer(int val) : m_val(val) {}
operator int() { return m_val; }
Boolean operator == (int val) { return Boolean(val == m_val, m_val); }
Boolean operator == (const Integer & val) { return Boolean(val.m_val == m_val, m_val); }
private:
int m_val;
};
int main() {
Integer a(10);
cout << bool(a == 15 || 10) << endl;
cout << bool(a == 15 || 11) << endl;
cout << bool(a == 15 || 11 || 13 || 11 || 0 || 10 || 5) << endl;
cout << bool(a == 15 || 11 || 13 || 11 || 0 || 9 || 5) << endl;
return 0;
}