??????????
???????C++??????
??????????????C++?????校?????????????——.cpp?????.h????????校?.cpp?????????C++???????????????C++?????????.h?????????C++???????????????C++???????
????C+ +???????“??????”??separate compilation????????????????????械????????????????????????????.cpp?????.cpp????????????????????????? ??compile??????????????????????????????????????????????????????????????????link??????????纾�?????a.cpp?卸??? ???????????“void a() {}”?????????b.cpp??????????????????????????????a.cpp?????b.cpp??????????????????????????????????????斜??? ???????????????????????????????????????
????????????????????写???????????????????????b.cpp?校?????? “void a()”????????????????????????“void a();”???????????????????????????b.cpp???????????????????symbol table??????“void a()”?????????????????????????????????小????????????????????????????????????????????????濉�?????????????????? ????????????
????????????????????????????“????”???????“????”?????????“????”??????????????????????????????????? ?????????????????????????????????????“????”?????????????????????????????????????????????????????卸???????????????????????? ??????????????????????????????伞????????????C++?????????????????????????????????????????????????写???????????????? ?????????????????????????????锌??????????危?????????????????巍??????????????????????????????澹�??????????????
?????? ??????C++???????????????????????????????写????????????????锟�??????????????????“void f() {}”?????????????械????.cpp????卸??????????????????????????????卸?????????????????????????????????????????????????????? ?????????????????浠�????????????????????????????????????????泻眉???????????????????????????????????????????泻?????????? ???????????写??????
????????????????
?????????????????????????????????????????????????????????????????????榉�??????????????????????????????????写??????????????????????????????????????些???????copy????????????小?
?????? ????????????校?????????榉�?????????煤???????????????????????????????????谓????????????????????.cpp????械????????????????? C++??????????????????????????????械??????????????????????校???????.cpp????????????????????????????????? “#include”?????????.cpp????校???????????????????.cpp??????????.cpp??????????????些???????????.h?????????? ?????
??????????????????????械?????????????????f1??f2?????????????????????math.cpp??
????/* math.cpp */
????double f1()
????{
????//do something here....
????return;
????}
????double f2(double a)
????{
????//do something here...
????return a * a;
????}
????/* end of math.cpp */
????????“??些”?????????????????????math.h?校?
????/* math.h */
????double f1();
????double f2(double);
????/* end of math.h */
??????????????main.cpp?校???????????????????????????????????????????
????/* main.cpp */
????#include "math.h"
????main()
????{
????int number1 = f1();
????int number2 = f2(number1);
????}
????/* end of main.cpp */
?????? ?????????????????????????????????.h???????写???????????????????????????????????????????????main.cpp????????锟�??? main.cpp??math.cpp???????????????????main.o??math.o???????????????????????????????????????????