??????Ч???
????????????????????????????????????????????????????????????Ч?????????! ?????????????????????????????Ч??????????????????IDE?????????????????????????????Ч??????????????????????????????????.
???????????C++???????????Щ?????????????????????????. ??????о????????????C???????.
???????????
????????C++????????????????C++????????????????????????????.??????????????????????. ????????????????????????????????????????????. C++???к??????????????????????????????????????.
????????????????????е???????????:
????· ??
????· ???
????· ????????
????· ??????????
????· ??????
????· ??????
????· ??????
????· ???
????· ???
?????????Щ??????????淶??????譚?????????У?????
????· ??????????
????· ???????????
????· ??????common????
????…
??????????????淶??????????????????????У??????????????. ???????????淶????????! ??????????????????????????????????????????????Χ?????С???????????ò????????Χ.
???????C++??????????Щ????????????????????:
????· const
????· ???????????η?private??protected
????· ????namespace
????· ?????????????
??????Щ?????????Щ???????????????????Щ????????????????????С???ò????Χ. ??????Щ?????????????о???????????????????????????????.
?????????????????????????????????????????ù???????????????????????????????????????????????????????????????С???.
?????????????
????????????????????????????Ч?????????????????xUnit?????????????????????С??鼶????в????????????.
?????????C++?????????xUnit?????gtest??Testngpp??CppUnit??CXXTest???Boost Test??. ???????????????gtest????????ù???????????????????????????????????????????????????????????. ???gtest?????????????????????????????????????????????????????????????????????????????????????黯???μ???????????????????????????????????????????????????滻.
??????????????????????????C++????????????Testngpp???????????????????????????????????????????????gtest?????????????????????. ?????????????????????????????????????以??????????????. ????Testngpp?????黯?????????????????????????????????????. ????黯???????????в?????????????????滻???????????????????????μ?mock??????.????????Testngpp???????????????Щ????2???gtest???????.
?????????xUnit?????????????????Mock?????????????????????.????C++??????Mock?????Mockcpp???????! ??gmock?????????????:)! ????Mock?????????????????1?????????????????.????????????????????????????????????????????????????????????Mock??????.???????????????????????????????????.
?????????????????????????????????! ???????????????????????????????! ??Щ?????????????????????????????????????????????????????. ???????????????С????????????????????????????????????????а?????. ??????????????????????????????????????????????.
????IDE
?????????????Ч??????????????????IDE.????????????????????????????Ч???????????????????????????????????????????????Ч?????????…
??????????ù????Щ?????C++ IDE??:
????Visual studio C++
??????????????????????????????????С??????????.?????????????????????????????????????????????????????е?#include????????????????.???????????????????????????????.?·?????Visual studio 2015??????????????????????????????????.
????clion
????Jetbrains???????????C/C++IDE????????????C++ IDE. ????????????????????30?????????????CMake???????????64λ????????á? Clion?????????????????????(???rename??inline??extract??Pull member up/down …)??????????1.0?汾?????????????????????????.
????eclipse-cdt
???????????????C++ IDE. ?????????????. ??eclipse??????????ù???????????????. ??????????????????????????????????????????. ??luna?汾???????????????????????????????????滻????#include?е?·????. ???????????C++ IDE.
??????????????????????IDE???????????????????????Ч??. ??????????Source Insight???????????????????????д???C++????????????????????????????IDE????????????????????????????????! ?????????????????????ó???????????!
???????????
????????????C/C++??????????????? ?????????????????????????????????????????????????????????????????????????????. ????C/C++?????????????????????????????????????????????????????????????????????????????????????????????????????. ????C/C++????????????????????????????????????makefile??????????#include?????. ???????Щ???????????????鼼??(make????????):
????· ??????????????????????????????????. ????????????????????IDE??????????????????.
????· ????IDE????????????????????????????????/??????????????????????IDE??????漰?????????#include????????·??????滻.
????· ???IDE????????????????????????????????????????eclipse????ctrl+shift+n
????· ????IDE????????壬???????????????Include Guard???Unique Identifier???????????????????????????Include Guard?????£?. (?μ?eclipse mars?汾????Windows -> Preferences -> C/C++ -> Code Style -> Name Style -> Code -> Include Guard ????? Unique Identifier??????汾?????workspace??????????????????????google????).
????// Runtime.h
????#ifndef HDEA41619_5212_4A92_8A09_3989000E6BAE
????#define HDEA41619_5212_4A92_8A09_3989000E6BAE
????struct Runtime
????{
????void run();
????};
????#endif
??????????
???????????????????????????????????????????????±???Ч????′?????????????????. ??????????ι????????????????С?????????????????. ????C/C++????????????????????г????????????????????汾??????????. ??????棬????????????????????????????????????????????????????????б???.
????????????????Щ???????????:
????· makefile?о??????????????.??????????.?????????????????????????????????????????makefile.
????· makefile?????????????????ù????????????????Щ???????????????????????????Щ??????????????????.
????# makefile example
????...
????SRCS += $(abspath($(shell find $(SOURCE_HOME) -name "*.cpp")))
????OBJS = $(subst $(SOURCE_HOME)??$(TARGET_HOME)??$(SRCS:.cpp=.o))
????...
????$(TARGET_HOME)%.i : $(SOURCE_HOME)%.cpp
????$(CXX) -E -o $@ -c $<
????$(TARGET_HOME)%.o : $(SOURCE_HOME)%.cpp
????$(CXX) -o $@ -c $<
????$(TARGET):$(OBJS)
????@$(generate-cmd)