diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-07-21 03:21:00 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2019-07-21 03:21:00 +0700 |
commit | 029688e143109344989b1529259e391822abb0aa (patch) | |
tree | 556f96273a5caed7df2e70a6ba253bcc7627bd33 /cpptour/enumcls.cc | |
parent | be6678fbca007e73d69c9a9c5cddb8241a987149 (diff) | |
download | cp-029688e143109344989b1529259e391822abb0aa.tar.gz |
[cpptour] Learn the basis
Diffstat (limited to 'cpptour/enumcls.cc')
-rw-r--r-- | cpptour/enumcls.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cpptour/enumcls.cc b/cpptour/enumcls.cc new file mode 100644 index 0000000..2340f65 --- /dev/null +++ b/cpptour/enumcls.cc @@ -0,0 +1,28 @@ +#include <iostream> + +using namespace std; + +enum class Color { red, blue, green }; +enum class TraficLight { green, yellow, red }; + +TraficLight& operator++ (TraficLight& t) +{ + switch (t) + { + case TraficLight::green: + return t = TraficLight::yellow; + case TraficLight::yellow: + return t = TraficLight::red; + case TraficLight::red: + return t = TraficLight::green; + } +} + +int +main () +{ + Color col = Color::red; + TraficLight light = TraficLight::red; + TraficLight nxt = ++light; + // ugh now we test if it compiles? just wanna build some muscle memory +} |