summaryrefslogtreecommitdiff
path: root/constructor-constexpr-test.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-10-02 11:23:38 +0200
committerOskar <[email protected]>2024-10-02 11:23:38 +0200
commit3edb35c6cab27d36f0fde49726db8cc9289e7304 (patch)
treedb59c3d208843079f462f4df63ffeec1d2fe4897 /constructor-constexpr-test.cpp
parent18236447ae6c08ff336fd22d191343a1ff9dfede (diff)
more
Diffstat (limited to 'constructor-constexpr-test.cpp')
-rw-r--r--constructor-constexpr-test.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/constructor-constexpr-test.cpp b/constructor-constexpr-test.cpp
new file mode 100644
index 0000000..ee2a06e
--- /dev/null
+++ b/constructor-constexpr-test.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+
+/*
+ *
+ *
+ *
+ *
+ */
+
+class Debug {
+public:
+ constexpr Debug(bool b = true): hw(b), io(b), other(b) { }
+ constexpr Debug(bool h, bool i, bool o):
+ hw(h), io(i), other(o) { }
+
+ constexpr bool any() { return hw || io || other; }
+ void set_io(bool b) { io = b; }
+ void set_hw(bool b) { hw = b; }
+ void set_other(bool b) { hw = b; }
+ void printDbg() { std::cout << hw << "\n" << io << "\n" << other << std::endl; }
+private:
+ bool hw;
+ // hardware errors other than IO errors
+ bool io;
+ // IO errors
+ bool other; // other errors
+};
+
+int main () {
+
+ /*
+ From page 299-300, i just needed to confirm what the code is doing.
+ */
+ Debug d1;
+ Debug d2(true, true, false);
+ d1.printDbg();
+ std::cout << "------" << std::endl;
+ d2.printDbg();
+ return 0;
+}