Koj puas xav tau program hauv C ++? Txoj hauv kev zoo tshaj los kawm yog ua tib zoo mloog cov piv txwv. Saib ntawm qhov yooj yim C ++ cov phiaj xwm kom paub txog tus qauv ntawm C ++ program, tom qab ntawd tsim cov phiaj xwm yooj yim koj tus kheej.
Kauj ruam
Kauj Ruam 1. Teeb tus compiler thiab/lossis IDE
Peb qhov kev xaiv zoo yog GCC, lossis yog tias koj lub khoos phis tawj siv Windows, Visual Studio Express Edition lossis Dev-C ++.
Kauj Ruam 2. Sim qee cov qauv kev pab cuam
Luam thiab paste cov cai hauv qab no rau hauv cov ntawv nyeem/code editor:
Txoj haujlwm yooj yim no yog muab los ntawm Bjarne Stroustrup: koj puas xav tau ntau tus thwjtim? (C ++ tus tsim tawm) los tshuaj xyuas koj tus neeg sau:
#include
Txoj haujlwm kom pom qhov tshwm sim ntawm kev ntxiv ob tus lej:
Qhov kev zov me nyuam los nrhiav tus nqi nthuav tawm:
Kauj Ruam 3. Txuag cov ntawv no ua.cpp cov ntaub ntawv nrog lub npe uas qhia txog txoj haujlwm
Tsis txhob poob siab, muaj ntau ntau qhov txuas ntxiv rau C ++ cov ntaub ntawv, xaiv ib qho (piv txwv *.cc, *.cxx, *.c ++, *.cp).
INSTRUCTIONS ': Yog tias Txuag Raws Li Hom kev xaiv tshwm: {xaiv "Txhua Cov Ntaub Ntawv"}
Kauj Ruam 4. Sau ua ke
Rau Linux cov neeg siv thiab gcc compiler, siv Hais kom ua: g ++ sum.cpp. Cov neeg siv Windows tuaj yeem siv ib qho C ++ compiler, xws li MS Visual C ++, Dev-C ++ lossis lwm txoj haujlwm xaiv.
Kauj Ruam 5. Khiav qhov program
Rau Linux cov neeg siv thiab gcc compiler
Hais kom ua:./a.out (a.out yog cov ntaub ntawv ua tiav uas tsim los ntawm tus neeg sau npe tom qab kev sau ua ke.)
Lub tswv yim
- cin.ignore () tiv thaiv qhov kev zov me nyuam los ntawm kev ua ntej ntxov thiab kaw lub qhov rais tam sim (ua ntej koj tuaj yeem pom nws)! Nias ib qho tseem ceeb yog tias koj xav xaus qhov program. cin.get () ua haujlwm zoo ib yam.
- Ntxiv // ua ntej txhua cov lus pom.
- Tsis txhob ntshai sim!
- Yog xav paub ntau ntxiv txog kev ua haujlwm nrog C ++, mus ntsib cplusplus.com.
- Kawm C ++ programming nrog cov qauv ISO.
Ceeb toom
- Koj qhov haujlwm yuav poob yog tias koj sim nkag mus rau tus lej ntawm tus lej hauv ib qho ntawm "int" sib txawv. Vim tias tsis muaj kev ua yuam kev, koj qhov program tsis tuaj yeem hloov tus nqi. Nws yog qhov zoo tshaj los siv txoj hlua lossis pov qhov kev zam.
- Zam Dev-C ++ kom ntau li ntau tau raws li qhov software no muaj kab ntau, cov neeg sau ntawv sau tsis raug thiab tsis tau hloov tshiab txij li xyoo 2005.
- Tsis txhob siv cov cai tas sij hawm.