---------------
Christof Meerwald@freec++.prog

home
> prog
>> freecpp
>>> switch stmt cond

translate to German (by SYSTRAN)

Switch Statement Condition

> switch_stmt_cond.cpp:

int Bc = 0, Bd = 0;

struct B
{
  B(int i)
    : i (i)
  { Bc++; }

  operator int() { return i; }

  ~B() { Bd++; }

  int i;
};

int main()
{
  for (int i = 0; i < 2; i++)
  {
    switch (B b = i)
    {
     case 0:
      if (b != 0) return 1;
      if (Bc != (Bd + 1)) return 1;
      break;

     case 1:
      if (b != 1) return 1;
      if (Bc != (Bd + 1)) return 1;
      break;
    }
    int b = 0;

    if (! (Bc == (i + 1) && Bd == (i + 1))) return 1;
  }

  return 0;
}
---------------

This Web page is licensed under the Creative Commons Attribution - NonCommercial - Share Alike License. Any use is subject to the Privacy Policy.

Revision: 1.2, cmeerw.org/prog/freecpp/switch_stmt_cond.html
Last modified: Mon Sep 03 18:20:50 2018
Christof Meerwald <cmeerw@cmeerw.org>
XMPP: cmeerw@cmeerw.org