Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
#include <iostream> using namespace std; extern int i; int main() { i=10; cout<<"the value of i is"<<i<<endl; }
'extern' は、i が別のコンパイル単位で定義されていることをコンパイラーに伝えます。そのためのストレージは作成されませんが、エラーが発生したときにリンク時に検索されます。したがって、i が定義されているモジュールとリンクするか、'extern' 修飾子を削除してください。