我把两个程序合并在一起,当然所有全局变量也合在一起了。本来以为,会出现很多错误,因为很多变量重名,但是编译却成功了,仔细一看,原来变量重复并不报错。比如 int a; 。。。 int a; 编译能通过。 可是:我却希望编译器能当作错误处理,因为我这些同名的变量在两个程序中是用于不同用途的。现在不报错,怎么办? 如果是警告,那么警告号是多少?就是那个warning c....什么的。
The scope of a name is the part of the program within which the name can be used.
For an automatic variable declared at the beginning of a function, the scope is the function in which the name is declared. Local variables of the same name in different functions are unrelated. The same is true of the parameters of the function, which are in effect local variables.
The scope of an external variable or a function lasts from the point at which it is declared to the end of the file being compiled.