gpt4 book ai didi

c++ - 跨不同功能使用 Goto 功能

转载 作者:IT老高 更新时间:2023-10-28 22:33:23 24 4
gpt4 key购买 nike

如何在不同的函数中使用 goto?例如:

int main() {
// ....
REACH:
// ....
}

void function() {
goto REACH;
}

最佳答案

你不能在标准 C++ 中。 C++ 语言标准 $6.6.4/1 起

The goto statement unconditionally transfers control to the statement labeled by the identifier. The identifier shall be a label (6.1) located in the current function.

...或在标准 C 中。从 C 语言标准的 $6.8.6.1/1 起

The identifier in a goto statement shall name a label located somewhere in the enclosing function. A goto statement shall not jump from outside the scope of an identifier having a variably modified type to inside the scope of that identifier.

关于c++ - 跨不同功能使用 Goto 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17357199/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com