Partial preview of the text
Download OOPS Placeholder Document and more Schemes and Mind Maps Computer Science in PDF only on Docsity!
| penance aE a 7a i gos 4 i ce i a = ae goge ther tne detg = —— Saeeoate cain ecig OOM ee = “hem 20 = 2 and the funchone eae ats dictate mG gWer pork of emetic £0, except shia ~-funerlon | he ee | whieh. boda (Class ty SESviee @ (uSen defined data types a ®ta own data Members and member Funchon’ -whig con be accessed and ysed b&b creating, an cae: of shot claga- Object : When a clase ts defined no memory iS allocated but when Tk 18 “instantiated re Be is crected) memory iB allocated, } Encapsulation = In oor , Encapsulation ‘8 defined as binding. together tne data and tne functlona that manipulates Shey \ 1 Abstraction: Abstraction meang display(ng only essenrial information and hiding “Whe detent, @ Aboracton using closker ~Apstaaction usith Header fier Cmatny = pow) q Falymorphism | “din Simple word? ,we can define Poly mor nis" as the ability of 4 MESSage tp be 4 oe mere then ene form. + Operator overloa dina, + Function overloading S fne Sum ClO, 20 , ae) 1 OOPS by Arpit hheritance 2 “the Ca pabiliny af a class to derive” fra properties and eharocterlaticz from anetner t Puncrion pecomes tacal fo Wot Rumerion ond cated joca\ Blass - ie: wr, — A she ease R&naide. the class ven of lecat _ “elass ih nus ne ~ dehined Function _ “and ~ Runtime _ Roly more prism : a 2 a membes Sie ciot Sante Clawe myauchiid vedefined — \ierual dered clage - geciared with Vietual Key Word i4 = base Clase, iy —. Ls Exception Handlin Sq) Gees 3 e358) a bieck ef cote that car AhreW e an ExcePio4 + lock, of code rihar geT executed Caren 3 tceltantr & 15) Reon ene: (6 ona Syme | Use te Byww On exception: 4 OOPS by Arpit a - = Cate, were HQ Speciainheae? 2 aan —— Se aver | eh Ce : a At catches all (eS joceeee ot = ae —- be (iia at eS eee | {a Tntfne Funetion SS Se ae mor peommand . lineé When a req ve Br he —> ‘mtine 78 - oT te “Unetonw chee te apanded 30 0 See : ened -.\When aee “eine. -ameran S28 colled vewminse - Code ger Snserted or Suvetttvted at the poe of ¢ a furenon” call, — fine verm=type fund ) — 4 ee 4 _ Gis ECTS MAT ENCE aT aiinee have same name & ~ * Function Overloading Ts Fi two or more fundtions can y Ai fferen+ porameterz « “i Void prink (tnt 2) Ez : ae u ' w 2 j Hh Utes Here ig fae" 2. ey endl ; di ie Ntoid print (@eatevae » E 4 ___ cout << " Here ig float” co = an Endl 5 & Q ss fu malty 4 Print (10) } tae iat (lord) yy I 5 OOPS by Arpit A ak =. | 3 - Tcchon (ap diesimiler 4leman 2+ Stryeture ie Sle ee | — aan ja ee ie | + Static Members Gees Sa a _— “Static variable in a Function + When & belle | H declared as Static , space tor cig pe ee a a lifetime of tne program , (defaut Frrtalized to oO) : i Even (‘€ the funcrion {e cailéd space. -for T+ {8 aiocated once: multiple times th, ae : Static variable tn @ class - — Declared ‘inside the class bedy é i => Also known ag closs. member varidble . i =a “They must be defined outside he class. Fl 7 Statle wvartavie doesn'+ belong te any Object , burke “+n€ Whole Close . N oS i Se rere) Maen Tbe omy x Copy ef static member variabe 3 for ne Whole clage. y! Ex class Accouns— F: at Wate + fint 'oalance a Storie tek yor ; B SS ee | (pened ti Noid Setfaiance Cint bs) a balance =h 3 j | b __ Mintalised outside oss Sloat = Accom +5 xe i = S57 | Veld main f Accourt a4 5 4 rem = OOPS by Arpit 7 ebbject san aso be declared babe CB Bravia. Sone Account aL; — 2 Srarte tuncrion An amIRClesous | oS ——$+_—_—____ Storie member funcriong © are alowed to ocess | ane Stove data members et other State funcsionz . ree ar i ~ eConstructora + = ——— = = Constr ctore ‘SB am special member. yfuncrionn ef tne le ClOgS . Be le automaticaly fnvoked when an ey ect iS) created. q 3 Sens.) 71a re+urn type: 4 Constructer hos Same vname = as i ae = Sf we do mot specify ethene comp\er generates Q default — covmmtructor for us Nl Consirverar Defautt forometerized Copy Crass amet) - Class mame (paramererz): “Qlage_name (gone : Ciass-name Loo) update) perm updorerdterin, Aum q) oh | vwpdare(conshiipdare a ‘i y San &R) bGer0 2 nant Ga 4} 4 A= Paa j ¢ np 2s" > oy = bay) be P25 oe 8 OOPS by Arpit L—Senvetor | s pestwetos 12 a member Pounerion winien }— deletes an object i cna ws {> pes wuctos don'+ Anke any argument ana i fFoxe = any yerurn type 7 5 Only one destructor ig possible = dDesrructor eanney be = Steric. ae, RET desivuetor doesnt destmy ob\ect Re ; ia the “jast Lunction that “Anucked before opject destey., estrucths or “gent La—_) _———“objeer- Resource Oestructer 1% used, So ~Ahat belore Aelerion of by we dan ree space Allocated for -thi& vesource . % fe ’ i ob\ oetB delebed then | space Allocated for ob) Unl be free bot yesource = Coean't . a Operator Overloading. c++ nove “he abitity to provwice special meaning ao ane operttor. q class Com plex il es Complex operator + (Complex Get) 4 Comp \ex eR | ree. G= cvd } KEBo (Sc 24.5 4 10 OOPS by Arpit + Soke \ divect| ie a0 aan ae Compan TB AICS : Wee Meme bo gS —~ Gan detine a function A = - i : ¢ Te ee p@lore “it nie __meed write operator hee So, wea Use @ all ieee — | Friend Ciass ee 7s, CEE aq amees e private and roreEe SS. , members of ome class tm which Tr (8 declared Se friend. _ “Were Gin be frend clase and friend fiction. i Ex: Clase BOK Lae Dg f 4 privere 5 4 } dable widin | eae L. ; pe bile ¥ a friend oid printwidth © Box box); i; Neid Serwidin( dewble Wiha); i. Void) 80x25 Seiwidth (Box double Wid) j 4 Mens Wi its } Void print hs) tetty C Boy box) [ 4 Govt <2 boxswiddh | =e a. | Ee: Snr Maink) | 4 Bort be x } Pox) SCLWiaty ( ayy Print Wictind box) s : SS aa 1 — OOPS by Arpit a Class Be publie Al, public AZ. Lael a i $3 -_ r a i, i A : a). Heivarchia| Thheritance a | p: = same 2s ai Class By - Poblic A Ms | S jl eless 82; Public A ? = i Nisi bility Mode : _ a 2 rivare =F ie a ie Pubic — cS. q A—base Gloss 7 nnn B- Sub Clags ie Fi wl ke Seay beste Prlvate A : : = i | — CretOcresa|— 13 OOPS by Arpit a and NAST I ning Mode ie public. Die eee Sac Pea qt =< aa. > (ama ey vez ool Naren public, Member Wit) be poeple faq By cand proteac wit erevecred , oF A - “4 aa Mode is Private then both proteded | ana FUblicY Member of A wit be Orivete meriberq Se Poae o Relationship is always ample mented az ta) oe | | = 2 — Constructor and pestructor fn —hheritonce r Flrat child class Conetrucror wih Ton au riag creation OF abject Of Child (ean ,- but as soon ds ob} & [a fea ||«OLAslasS «= Coretrueter” en fend HW wit, sal Onatwerr of 4s gorent lage and atres Ane &eu of parent dass menses TE will wearme TH consrne eeecattion , T GHid Se ater conetruens Call J : ema qo: Ae) i 4 constructay EXEr, q a if é T Eat GHIA Gena | While an cafe << ACID Vy CTOs) | £ A z yuotor exea 4 vB entid aes shen fF +" dea, exe cured. (a te n q n (ee re mae wipes see wre Cont ral ere ch “4 OOPS by Amit \B achieved at Compile time, is gearns 7 a 4 net Vold ehange_gear ( Qnt aear) ed 4 = Rea y LL PEELLY Clase SporizGr + public Car 4 void change -c as C Bor gear) Bel d mt car > 5) 4 raed | COL a +) = } an - Ant min |) GST RS a Beye) i ac. oe CAs eel | ea at r 4g Gr Cass will be called. a change — be get aliing Claes. oh erwit V 4 function of fer a eae ah nec TF any fon aycsnis qed ; for al except one Car oF ala i é 16 OOPS by Arpit - vy ~~ = Viviwal Fonction =a See: Virtual function ig a member Eee a = declared Wits a Tirta’) ¥eyWard i 40 wr i Fi sive —_ 9nd fedectared (overridden) in @ desived clagg i When yo refer 40 4 ee a Ee wal N—__poister to a bose cas, ym con call Viera) Fang oa of that Obyect and execute the derived close {i Nersien of -+ne fonction. a ps ENE SI OGG E = * They ore used to aewieve Run time fly morehiam . 4 Pe Nittus! Fenétion annie Se Sauna and Qiga Cannot be Trp, re lee function of nother clogs, eS = Compile -+ime ( Early binding ) Ve Run-time Chote Binding) [. q ca. ee ke Closs bage Lu 4 Pubes a Nittal void i a. | i 4 Gupec % i HZ lf bege print” << Endl} 7 | void Show ©) 4 Gout ci ¥" Bose i Stow fon! ce endl; | alass = derived 4 se Publican Biw ee) 2 ; Vold Print< J} F Ce Bea phi soread” aay nay Cine’ eeenays ) void show0) , ; : OOPS by Arpit = a | VTABLE for bap | NPTR om — Ye iy) - 5a VTABLE for derived Gp br4 > a qv \ ~ Pure Niytval Funetion = ST and abstract Class is - | Sometimes impiementation of ai function annot be bys, S ‘n she base Claaz, Sven a Class 18 caied Abs trae ci > dyvawd) : ¢ : (Shape | <3 (Bot there: alt bean) E pi implement=ten oF day ; my — \ Square | ar base chess; re Av pure virtual banction an c++ 1a-. a virtual function ie eoMinien «we | doo hove any ‘implementation, we only deowr BE Soy r 7 ry 4 “4 @ostract Clags ; (tS¥ 2 Clos TP ERY FolsnuF 1UTYIA Fo anlar. : ; ubve | a = = = e Core Vive var function i gato ae Se Se 2a ee PRP meine mary aimee 4 19 OOPS by Arpit ——— ss ae declare “abject of absrroct ClOBA * ie = Teet = iweb aman aren ean Ce mei ae ar a a : we can have polrer = = apaneeio aa ee he [ean Secease_ower eo object of VTS derived alas; — = we dont override +ne ouve Tiere, ~fundton [ a —¢. derived clepp hen t+ Becomes Tanerects = b in ae Aa eee class Can ane» eonstrucrorB = a wee =e an Gta te ea 9m wen meee Gigs ap x ey _ ees Se eS | q pe: yh _ __— Aro sare llae SS ee <—$s yerurq af MS a ibe | a ae eee werurn by EEE Dak oh | ~ mar we CoN _ ae Tr doe \Us* nee in dose +yre aan eh be used cca fyn chien a wore faite ae ae ee ac oy a of menor is done ~ Ay nannies When all ocation \ocarar new Sin Const ructo! meme” class cas. ind = ee mew cure tb 0 ie oT mt main’? a= , —Ta a mew! aa 2p 20 OOPS by Armpit