您好我想知道如何引用變量「X」(主函數)的塊內:參考變量外塊範圍,但內部功能範圍(C/C++)
#include <stdio.h>
int x=10; // Global variable x ---> let it be named x1.
int main()
{
int x=5; // main variable x with function scope ---> let it be named x2.
for(x=0;x<5;x++)
{
int x=2; // variable x with block scope ---> let it be named x3.
printf("%d\n",x); // refers to x3
printf("%d\n",::x); // refers to x1
// What is the syntax to refer to x2??? how should I try to access x2?
}
}
我們在談論C和C++,而不是JavaScript。這是錯誤的。 – 2013-11-23 18:00:53
這個答案是明確的,危險的,錯誤的。 – poundifdef