chapter 8 :exerciser4:Create a const definition in a header file,include that header file in two .cpp files,then compile those files and link them.You should not get any errors.
#include"const_test.h" //#include"TheOtherCpp.cpp"////////////////////这个去掉注释可以吗?不要下面那句? #include <iostream> using namespace std; extern void f();//////////////////////如果去掉这句用上面那句就会出现i重复定义, int main() { cout < < "i in the main() is : " < < i < < endl; f(); return 0; }
3.TheOtherCpp.cpp: #include"const_test.h" #include <iostream> using namespace std; void f() { cout < < "This is in f() : i = " < < i < < endl; }