基礎
下記で、アドレスが同じになることは意外と重要な気がする。
スコープの問題らしい。
C言語だと重要なのかな。
// main.cpp #include <stdio.h> extern int count; extern void disp(); int main() { printf( "Main : count = %d, count address = %p\n", count, &count ); disp(); ++count; printf( "Main : count = %d, count address = %p\n", count, &count ); disp(); return 0; }
// extern.cpp #include <stdio.h> int count = 0; void disp() { printf( "Extern : count = %d, count address = %p\n", count, &count ); }