1 / 11

Programim C++

Programim C++. Klasat , Objektet , Instancat , Metodat ( Shembuj ). Hyrje. C++ u ndertua si nje ure lidhese midis OOP dhe C, gjuha me popullore e programimit te programeve komerciale ne treg . Lloji i te dhenave (data type) na tregon per: Madhesine ne memorie qe nxe

suki
Download Presentation

Programim C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programim C++ Klasat, Objektet, Instancat, Metodat (Shembuj)

  2. Hyrje • C++ u ndertuasinjeurelidhese midis OOP dhe C, gjuha me popullore e programimitteprogramevekomerciale ne treg. • Llojiitedhenave (data type) natregon per: • Madhesine ne memorieqenxe • Cfarellojinformacionimundtembaje • Cfareveprimeshmundtekryhenmbite • Ne ndertojmellojeterejatedhenash, sepsenaduhetteballafaqohemi me situatakuvetemnumratdhekarakteretnukmjaftojne (data types tipike)

  3. Llojeterejavariablave • Llojet e rejatetedhenave, krijohen duke deklaruarnjeklase (class) • Njeklase, eshtenjebashkesivariablash – zakonishtllojetendryshme – tebashkuara me njebashkesifunksioneshqekanelidhje me njeratjetren. Psh: njemakineeshtenjebashkesirrota, dyer, pasqyra, xhama, etj. Dheajoecen, ndalon, shpejton, kthehet, etj.

  4. Member Variables dhe Member Functions • Njeklase (class) mundesonqetebashkoshveprimetdhepjesetperberesene njekoleksion, dheketekoleksion ne e quajme OBJEKT(object). Kjo ka shumeavantazhe. • Variablat (ndryshoret) ne njeklasenjihensi: member variables ose data variables. Ketojanevariablat e klases (class variables) dhejanepjesetperberesetemakines: rrotat, timoni, pasqyrat, etj. • Funksionet ne njeklase, zakonishtmanipulojnevariablat (member variables). Ketonjihensi member function, osemetoda (methods of a class). Metodat e makines do teishin: nisu(), mbajFrena(), kthehu(), etj.

  5. DeklarimiiKlasave • Per tedeklaruarnjeklase, perdoretfjalakyce: class e ndjekurngakllapa{ , me pas listohen data members dhefunksionetqe do tepermbaje, dhe ne fund mbyllet me } • class Cat { unsigned intitsAge;unsigned intitsWeight; void Meow(); } • Kurdeklarojmenjeklasenukrezervojmendonjehapesire ne memorie. NjeklaseMace do tekishte data members per moshen, ngjyrendhepeshensiedhe methods per flen(), vrapon(), mjaullin() MosHarro: C++ eshte case-sensitive

  6. DeklarimiiObjekteve • Njeobjektillojitteriqejukenikrijuar, deklarohet ne tenjejtenmenyresikursedeklarohetnjevariabelitipit standard. Psh: • unsigned intMosha; //deklarojnjeinteger • MaceFrisky; //deklarojnjemace • Nëkëtërast Frisky eshtenjeobjekt e llojit Mace – ngjashem me Mosha, qeeshtenje variable e llojit unsigned integer • Objektieshtenjeinstancë e njeklase.

  7. Aksesimii ‘Anetareve’ tenjeKlase (class members) • Per teaksesuar members tenjeklase, perdoretpika (.) ose ne eng. ‘dot operator’. • Per tecaktuarpeshen e maces Frisky, shkruajme ne keteforme: Frisky.itsWeight = 50; • Per tetherriturnjefunksionteobjektit: Frisky.Sleep(); • Ne keterast, therritetmetodaSleep() e Friskyt. Data member objekti Method / function objekti

  8. Dhënia e Vlerave • Ne C++ vleranukijepetllojit, porvariablit! • Shembull: • int = 3 gabuar • int x = 5 sakte • Mace.itsAge=5 gabuar • Cat Frisky Frinsky.itsAge=5 sakte JepivleraObjektitjoKlases!

  9. Public VS Private • Edhepse ne ndertojmenjeklase, nukmundteperdorimtedhenat / anetaretqejane private. Per ketearsye, deklarojme: class Cat{ public: unsigned intitsAge; unsigned intitsWeight; void Meow(); } • Kjobenqe, itsAge, itsWeightdhe Meow() tejenepublike – dmthteaksesohenjashteklases.

  10. Sintaksa class classname { Access - Specifier: Member Varibale Declaration; Member Function Declaration; }

  11. Permbledhje PERDOR • Perdorfjalen class per tedeklaruarnjeklase • Perdorpiken (.) per teaksesuaranetaret e njeklase • MOS • Mosngaterrodeklarimin me caktimin. • Mosngaterroklasen me objektin. • Mosijepvleranjeklase, poranetarevetenjeobjekti

More Related