資源描述:
《Finalexamreview-BjarneStroustrup'sHomepage期末考試復(fù)習(xí)-BjarneStroustrup的主頁》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、ReviewforFinalExamChapters1–20(“ProgrammingandC++in75minutes”)BjarneStroustrupRonnieWardwww.stroustrup.com/Programming1Stroustrup/PPP-April2010AbstractThisisaone-slide-per-chapterlightningtourof“Programming:PrinciplesandPracticeusingC++”intendedforuseasareviewlecture.Itcanbedone
2、asa75-minutelecture,butismuchbetterastwosessionswithplentyofinteractionandstudentquestions.Stroustrup/PPP-April201023TheAimsTeach/learnFundamentalprogrammingconceptsKeyusefultechniquesBasicStandardC++facilitiesAfterthecourse,you’llbeabletoWritesmallcolloquialC++programsReadmuchla
3、rgerprogramsLearnthebasicsofmanyotherlanguagesbyyourselfProceedwithan“advanced”C++programmingcourseAfterthecourse,youwillnot(yet)beAnexpertprogrammerAC++languageexpertAnexpertuserofadvancedlibraries3Stroustrup/PPP-April2010Chapter1-2ProgrammingWhyC++?Whysoftware?WhereisC++used?He
4、lloWorldprogramComputation&LinkingWhatisprogramming?IntegratedDevelopmentEnvironment#include"std_lib_facilities.h"http://headerintmain()//whereaC++programsstart{cout<<"Hello,world";//outputkeep_window_open();//waitreturn0;//returnsuccess}4Stroustrup/PPP-April2010Chapter3TypesBuiltin
5、types:int,double,bool,charLibrarytypes:string,complexInputandoutputOperators—“overloading”VariablenamesinC++SimplecomputationsLiteralsDeclaration&initializationTypesafetyProgrammingphilosophy//inchtocmandcmtoinchconversion:intmain(){constdoublecm_per_inch=2.54;intval;charunit;whi
6、le(cin>>val>>unit){//keepreadingif(unit=='i')//'i'forinchcout<7、onsCorrectly,simply,efficientlyDivideandconquerUseabstractionsOrganizingdata,vectorLanguagefeaturesExpressionsBooleanoperators(e.g.
8、
9、)Shortcutoperators(e.g.+=)StatementsControlflowFunctionsAlgorithms//Eliminatetheduplicatewords;copyinguniquewordsvectorwords;strings;while(
10、cin>>s&&s!="quit")words.push_back(s);sor