about summary refs log tree commit diff
path: root/lang/cpptour/enumcls.cc
blob: 2340f651e7f9f101dde49d47854f8d727535deca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}