我刚刚开始学习D.在C++中有::(范围解析操作符),如果全局变量和本地变量都有相同的名称,就可以从函数中访问全局变量。但是用D语言怎么做呢?考虑一下这个计划。
import std.stdio;
int a;
int main(string[] args)
{
int a=3;
writeln("D is nice");
static int i;
writeln("value of i is: ",i);
writeln("value of a is: ",a);
// writeln("value of ::a is: ",::a); compiler error here
return 0;
}
如何从main()函数中打印全局变量a的值?D提供这样的操作员吗?
发布于 2015-08-04 03:03:25
https://stackoverflow.com/questions/31807119
复制相似问题