我有兴趣了解编译器是如何解释语句的……</p>
项目类型是 C++ IDE 是 XCode 3.2 64bit 操作系统是 Mac OS X 10.6.8
注意:代码示例是一个无限循环。
在下面的代码示例或附加图像中。如果有的话,编译器在做什么。没有引发重大错误,也没有小错误(鉴于我当前的编译器设置)。最感兴趣的是了解案例陈述 C 中发生的事情:
bool nrContinue;
enum Task {
A,
B,
C,
D
};
nrContinue = 1;
Task nrTask = A;
while (nrContinue) {
switch (nrTask) {
case A:
cout << endl << "Processing task: " << A;
nrTask = B;
break;
case B:
cout << endl << "Processing task: " << B;
nrTask = C;
break;
case C:
cout << endl << "Processing task: " << C;
// --------------------------------------------------
// Below is the statement of my misunderstanding
D; // What is going on at this statement
break;
case D:
cout << endl << "Processing task: " << C;
nrContinue = 0;
break;
default:
cout << endl << "Default case was unexpected.";
nrContinue = 0;
break;
}
} // loop