0% found this document useful (0 votes)
22 views16 pages

Oops 01

oops notes

Uploaded by

anmolbansal1969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
22 views16 pages

Oops 01

oops notes

Uploaded by

anmolbansal1969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 16
Bo / 10/2023 ® Ghat {i ooPs is_o pragramnming, pevodign ox _— technique in chic. things evolwe osxcound the obyecks so _ s _L applications. Unceeases rea ability, reusabhity OPS relases progrromarrin “ath neal - fe, Tnasnageabili ty, 7 = Objeck Js om emt cohida hos _ Stare |properies amd be haviour |functions. a _Obyeut tnvity, . fy Store Behaviour _* | Class +) Gay is a user-defined or curtom dato. Hype. 2 [Claw is the blue-paint of the obyect amd object is +he instomu of class. ot Class animal £ %, int_moin)t Cours" size of empty, class: “ec sheof (amimel) She of empty class ig Lbyte + To keep the track amg do Tidentify that something Like Hs ; a Co ae z Claws exists , empty Class is allocated coith minimum pate which Ww addremable in. rnernory \-e- Paddings adde the one or more empty, bytes between the memorw, addruyes to allignn a data tn memory.” The preceomor doo not read \bute at a time. Sn_32- bit precesoy , procenmor reads 4 buses aka time and in 6u- bit ik reads © bytes. ASM Padding is_done to minimize the Ceu Cycles. class padding f Chan a + int b+ chan. c 4 Shonk ds int maind) Couk << sizeof (padding) thoy. ow marked pedivatte class © Stote | Properties ink a } [String str; | Behaviows [funclong an | |void Funct oe yf void func2 yt (toed obser ki propotin he acces kme he Sige dot (+) operator, ka we hota hal, Coded class amimal public: int Ages ink Goeight 5 Ut behaviowe: Noid eat () of cour cc“ cating "x und; Noid slept) Couk << “sleeping << endl; te +. int_ main ()¢ oval sau tftar eet Mf skoxie) Kommesh- age = 125 Somnesh » weight = US; Cout << Hamneshs age << md), S Gout Hammerh. cueight << end), L dase» eot () . sramesh+ sleep) » ae 45 eating = o sleeping aa TE ewe coomt to acces pxivode mumbou outside, Class, cue use getters oma setters for tha Getter amd Setter oe the funchons+ Getter fetches Yaw propery amd Setter Sek the value of Pevop untey . Code) class gpbSet £ privase : int values pwdlic: int getVodue 1 ata int _setValue Cine) ¢ vadue=v 5 % int maint) ¢ Moby) etSexk Num; mum. SetValue C20): douk de Num: astValue Oo Kenny __ Codes) *Fincluds age = 125 : lout <¢ Suxerh— age @ak (_) 5 ARAR omimal * surterh, RRPAR _ofpls 2 eating pe eotind eon vipPPRePe Gwaunt obec + aly Thin is a pointe, to the ) Coded] Hinclude chits|stde Hho Laing, homespace Std; J clay onimal f psivate + int coelalat , publics ine _gaxweight OE Saturn cwoeight 5 ink _settweight (int codgnt) Anis, = Coright = cwuight ; (Bthis). weight = wright ; . int main) ¢ a as O+ get weight 5 Q. sekWelght (So); Course Qe qurtdeight | ) age this > weight= 9; cour ce “constructor, calted"< emdl; int main () f amimas a 4 oorgtrucoh cabled 4 od ; an Note > Obyet iniMalisation bina constructor he bhi hor skte hal bur Using constxuctor lus comidered a4 good codings practces, Class omima) & public: ink _age + int coefgnt s String type 5. ounimal Cink ag. 08 Min > age = age; (our <<‘! paxameteriaad combuuctote | called ec endl; arimnal Cink agg, int weight) ¥ thy > AQe= aoe ; this > wight = weight; cour cc“ panamuerized constructor, 2 cabled ze end: 4 4. int maint) t amime) o (10). amimeal b (lo, 207: Parameterized constructor, | called - Parometerized comtnuctor 2 cabled | Obseck Oreotion nai zine Panomekerr por Rigen honge usbe ordi, comsducny coll gayegi: © aoe} Ty wpy “consbuctos ‘ulade lei : defout constructor Gwake koma . podlega. hi to error degax ae Class _omimal £ public int ages Line cotighs 5 amimal LL 43 amimal Comimal &obz) yf this > age = obj: age; _thte = couight = obty- weight 5 cour<< “ tom ear copy combucter "ee endl; 4: int maint )~ animay as PPP PR ARRAM MAP PAARRAAAARNNcelenaa animal b= a+ amimel _¢ (b)- amimal ¥ A= meus amimal ©), lo He inside copy, constructor, inside Copy. vonstuctoh are fe on om, op hh PID PP VeRRTTTS Ze a ae ominnal ( amimal obs) t SS amimal Qs by Wass Ws us Pass bu value Rane se sepeatediy, cop, bemeg' JThaa!s coh, copy. conmtraunor, oqain. amd again, Calt hoc amd infinite loop mai Ks Jotyed on To prevent this, pars by veference biyo obyect ho [imide copy. constaucton. | | | | | [Conuucton Creat: parte time object initialisation ko 4 - allovtion he hua tha waka _ f ODD VIB YY YY ayn caseiot stake detsnucor Js coded autorrasivally. => |Se__cone of dynownic _aMlocation, cleatnudtor. ts to a be calud, mona bly. «de hos no setwmn Aupe , Af No wmputr Porarnetens » | Te two has some name os clay rome, I | 1 | ft - = —— | | Nob bbb Ga we symbol PrHecedes destnuctons, - f/f a class _omimal £ « publics ink age. | HM derysiuctors) | camimal ()t 2 | Cour cc“ destoructon,, Called "ec und; & | 7 = = = int_moin() $ anima) ay = Gragg =125 oe ‘ ia a vaetenni® Her melawoniehd | lewis = ae 1 b page= i25 Gz ee i = = delere by = JOP AS derrtsuctos. cabled = ! dwstHUcoK Called = = oJ | Stack mumony, Re cose mai Th scope khim = ; & ho Tey jo automatically, call ho Jayna, oo dutsnucon amd heap memos, Re Case maf _ mamu' cot bein tpd : = oh. “ = = om a ~ = “ % e 29/10/2023 sit | Acceribte te ott functions. functions moi globo) Naviable ki copy anhi_bamti_, actual) momar, location | px kaam he wha hotaw hai, Coritten outside of functien, WP coven iwide of incon. Accenible inside the function Scope orb Code 5] 2 include

You might also like