C++における宣言と定義~~extern


      :           ,           ,      ,          。 
  
 

: , << , extern

: project ,

extern :

a.cpp int result=100; b.cpp c.cpp result extern, cpp 。

:

a.cpp

int result=100;

b.cpp:
#include <iostream.h>
int main(){
extern int reslut;         //     a.cpp  result 
cout<<result<<endl;
return 0;
}

にexternは、 の にも できます.たとえば、 のようにします.
a.cpp
void show(){
   cout<<"hello world!"<<endl;
}

b.cpp
#include <iostream.h>
int main(){
extern void show();
show();
return 0;
}

もちろん、b.cppは、 の と を きすることもできます.
#include <iostream.h>
extern void show();
void show(){
cout<<"haha"<<endl;
}
int main(){
show();
return 0
}
には「extern C」もありますが、これを ってC++がCの を び すことを するのは、 はCをよく らないので、よくわかりません.の