我的程序如下
//file test.cpp is a file which defines a const int which should have internal linkage.
//test.cpp
const int i=60;
----------------------
//file main.cpp uses the const int defined in file test.cpp
//main.cpp
#include <iostream>
using namespace std;
extern const int i;
int main()
{
cout<<i<<endl;
}
上面的程序编译和运行都没有问题, 但是如果test.cpp中i的定义变成 static int i=60; main.cpp 中的声明变成extern int i; 编译错误显示变量i未定义。请问internal linkage的意义到底是什么?
[此贴子已经被作者于2007-9-25 11:57:51编辑过]