Tabbas, na yi farin cikin rubuta labarin dangane da bukatunku. Gashi nan:
A cikin ainihin kowane harshe na shirye-shirye, aikin farko shine buga "Sannu, Duniya!". Wannan magana ta kasance al'ada ga novice shirye-shirye da suke samun kafa a cikin codeing. Shiri ne mai sauƙi wanda ya ƙunshi mahimman ayyukan harshe, yana sauƙaƙa wa masu farawa fahimta. Duk ta wannan, za mu nutse cikin zurfin C++, mu koyi yadda ake rubutu, tarawa, da aiwatar da wannan aikin tushen.
Rubutun Sannu, Duniya! Shirin a cikin C++
Don buga shirinmu mai zuwa, za mu buƙaci editan rubutu ko Integrated Development Environment (IDE). Rubutun Ƙarfafa, Notepad++, da Eclipse wasu shahararrun zaɓi ne don shirye-shiryen C++. Ga ainihin tsarin shirin:
#include
amfani da sunaye std;
int main () {
cout<< "Sannu, Duniya!"; dawo 0; } [/code]
C ++ harshe ne mai girma, don haka rubutun ya fi kusa da turancin Ingilishi, wanda ke da amfani ga masu farawa. Kuna iya ganin "#include
Bayanin mataki-mataki na Code
Kashi na farko na shirin, “#include
Ga rugujewar lambar:
- "#hada da
” - Yana da alhakin haɗa shirin tare da daidaitaccen ɗakin karatu na C++. - "amfani da sunan sararin samaniya std;" - Ana amfani da wannan layin don gabatar da sararin sunan std.
- "int main() {"- Wannan shine ainihin zuciyar kowane shirin C++.
- "cout<< "Sannu, Duniya!";" - Abin da ake kira cout, haɗe tare da << ma'aikaci, yana fitar da kalmar da muke so.
- dawo 0; - Hanya ce ta nuna nasarar aiwatar da shirin.
- Rufewa } - Yana nuna ƙarshen shirin.
A kusa da "Sannu Duniya!" aikin yana haifar da ingantaccen tushe don mafari don fahimtar tsarin shirin C++. Ka tuna, wannan shine mafi asali nau'i na shirin. Yayin da kuke zurfafa zurfafa cikin C++, dole ne ku yi aiki tare da ƙarin ayyuka masu rikitarwa, ɗakunan karatu, da ƙirƙirar naku!
Laburare da Ayyuka a C++
Dakunan karatu da ayyuka sune kashin bayan kowane harshe na shirye-shirye. A cikin C ++, suna ba da izinin sake amfani da lambar, wanda ke haɓaka aiki sosai. Mun tabo wasu dakunan karatu kamar su iostream a cikin "Hello, Duniya!" code. Akwai ƙarin ɗakunan karatu marasa adadi a cikin C++, kowanne yana da takamaiman tsarin aikinsa.
Yin aiki tare da ayyuka muhimmin sashi ne na shirye-shirye. Aiki toshe ne na lambar sake amfani da ita wanda ke yin takamaiman aiki. Yayin da kuke ci gaba, zaku koyi game da ƙirƙirar ayyukan ku har ma da yin lodin su don yin ayyuka daban-daban!
C++ yare ne mai girman gaske, kuma yana farawa da binciken ku da "Sannu, Duniya!" zai iya saita sauti mai ban mamaki ga abin da ke zuwa.