[英]Valid target for goto statement
I was doing a C++ test and one question puzzeled me a lot. 我正在进行C ++测试,一个问题使我很困惑。
What is the valid target for goto
statement: goto
语句的有效目标是什么:
&Label;
:LABEL
<LABEL>
Label:
:Label;
I think ;
我想;
has nothing to do with goto
statement. 与goto
语句无关。 It is a sequence point. 这是一个序列点。 So the only one answer would be 5 but <>
are not permitted in the label name, I'm very confused. 因此,唯一的答案是5,但标签名称中不允许使用<>
,我很困惑。
The correct syntax for the target of goto is goto目标的正确语法是
4) Label:
Though it would be more correctly to say that the target of a goto statement is a label itself because according to the C++ Standard (6.1 Labeled statement) 尽管根据C ++标准(6.1带标签的语句),可以更正确地说goto语句的目标是标签本身。
The only use of an identifier label is as the target of a goto 标识符标签的唯一用途是作为goto的目标
On the other hand the target of a goto statement is a labeled statement.:) 另一方面,goto语句的目标是标记语句。
So in my opinion the question is not clear whether it asks about the syntax of writing a label or what is the target.:). 因此,在我看来,这个问题尚不清楚,是否询问编写标签的语法或目标是什么。
I suppose that the question about the syntax. 我想这是关于语法的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.