0% found this document useful (0 votes)
35 views17 pages

Oops 1

Oops assignment notes

Uploaded by

nerkardigambar8
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)
35 views17 pages

Oops 1

Oops assignment notes

Uploaded by

nerkardigambar8
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/ 17
‘Mumbai Education Trust's INSTITUTE OF ENGINEERING, BKC, NASHIK. Department of Artificial Intelligence and Data Science Course: Object Oriented Programming (210243)’ Class: - SE (AI & DS) UNIT: 1/ Assignment-1 Q CO | Blooms No. Question ‘Mapped | Levels | a fompare Procedure oriented programming Vs Object oriented Go, | Ka K4 rogramming |Create a class “Student” with attributes like name, roll numbe 2, & mark. Include member functions to set & display these) ¢o} K3 latributes. Write a class “Calculator” with methods for addition 3. fubtraction, multiplication and division functions. Create a) COI K3 ject to perform arithmetic operation. 4, [What is difference between pointer and references? col K2 hhat_is_polymorphism? How does it relate to function 5 _bverloading? Colm ERS) 6, [State differences between abstraction and encapsulation. cor | K2Ks 7. |What are C+ access specifiers? Write down their significance! Cot | KI,K2 hat are the different ways to define member functions of al 8.__klass? Give Examples of Each. col K2.K3 tite C++ code that defines a class and declares and array 0} 9 _ [objects to that class. col K3 [Define inline function. Write a C++program for finding the 10 _larea of a triangle using inline functions. col K2,K3 Bloom’s Taxonomy Rubrics: K1 K2 K3 Ka K5 K6 Remember | Understand | Apply | Analyze | Evaluate Create Name of Students: Gra} kwoad Sumit pwn] Roll No: Due Date of Assignment: Date of Submission: 23\8 |2<- Sign of Subject Incharge: PaO iad Paro oy Ey ssisnment Ke O48] 4 Coompore Péocedure o@enked Peoqoamming Vs object » ovented Pecgcamming. Peece deme oviented object oFrended Peogeamming Peoqeamming 3 | Enphasis fs on doing thinge| Erphasis is on data rather not on dala y meann rt than Pee cedtne , * Meann TS Rmavon driven obyect daiven. » | main facoun 's on the fang.) main fecour ts 0 the data fon & Peacedure dhat ope- dyat fo being Operated. tate on data. i BD | Top down Appacch tp Peoqnam| BeTiom OP Appasch fp design | Pema desian i = it D [lorae Peoqram azedivided ip | lowe Péoqnam are divided te Galler Pesqram row an| voto crosses 4 ohpeet. Fenaron. | 3 | most of dhe Rincon Shave) @ata fs Hed Fegethes With 9 Jlobay data, fincnion in the data Shuckwe. Adding oF daka | 4+ fui? ditt] Add? oF data 4 faro dePawit | B | We cannot deciore name | We ay use name Space fos pace decay 5 diveay, Et. Osing Namespace sii! BLER SG Rete | Pasay, | xi ct, Tava, 235, ete | ete t 1 » Cerate a class “ Student? With attwibuer like Name, 20 NO. 4 Mork | Fnciude member Runay to set 3 drsPlay Ayese atttibuber, . st inctude < fosheam > # {nctude < Shing > Using mamegpace Std 5 Class) Student 7 Pelvate + Shing’ Mame } tot vol No 5 Float mark + Publre I) Members Puncn'oo 4 Set Student defaila. Nord Set defaille Cshng Shident Name , int Sere Roll No, Float Student mork.) Pame + Stident Name 3 a RON NO = Shudent Roll Nos Tork = Shident mark 5 4 I} wember “Panchon” ty display Student detaile . Nord dismay. Aelailn OL | Cowt | 4+ inctude < foskeam > Stass Calcwator 1 publre ¢ No method Rr Addit’od double add Cdouble 9, double b) 4 j eeran at by 1 tmelhod RE Subbach’oo be double Subpact Cdouble 2, double 4) eu I 3 acon a-bs Il method) Re mut'phicab'ao double multiply (douba, dou b) j 4cqon a * bs I) Method fea division double divide Cdouble ¢, double b) 5 ip Ch==0) q Stayt Cea <<" Extey: oivicion by rem! > Num a2, Std 2) Cout <<" Ent OPperahion CH, —, + Std =) cin >> OPewaton double tesurt 5 witen Copranon) 9 Cage | +75 resuit = Cale. add Cnumi, num?) + boeak + Case ~? + tesult = care. subhact Crum), numa)" beeak 5 reset Aieey reesult = calc. multiply Coumi, num 2)! baeais Gases t fos rResurt = cate. divide Cnumi, Puma) : boeak 5 Ikawt + shld ty Cer <<" Fnvalrd opevabion 1’< | Gan be nw Ci-e Point to po Vatrd memory Address) Cannot be pw, must aed acer do an existing objet | Can be reassigned t© point: Gannot be Peassigned do AiFe. ob) oF memory lo- artes lnitilized. Canoe, ns wy | Can acess 4 moanipurake tux memory addoess Osing Cannot digecny access 0& manipwaken memory fa oP erator ec, Address. _— Typicaty oCeurrer Memory Csize oF pointes 4 ov 8 byter), usu ally Addit¥tonas memory head @y 41g an aoe No ya seek ate Sees | & [can beiniHatacd te na | myst be lott Waxed saben any Maud memoy Addess | dedaved and Cannot be [eft Unini Haired. | t | j D [Gan dectore gq Gnstant | San be made Gnstant vig Con pointes CT @nst pte)ov) keywoed | meaning tu a Poinky to a Qostant | ReRerence tsa h Gan't Cconst’ Tt ptr) Ghange 3 [Can have mune Jevae| wo mut Ply evel of indivechdo por indiweci'on Cent pointes || C Mo PePerence te acference) do poinks SJ What fs polymorphisms 2 HOW doer ib Relate fo L fircron + Ovewloading & | — | Polymorphism: — 2 Polymorphism Meann tte abilrty fo make moze dhan one feom, + 2 allems 9 Single name te be Used ae mote fran one Reiated PUrPose. 2 It meanc abiiity oF operalorn and Runcy’on to ack diffenentty th dIRF. Situation, + dr PES tuper OP Polymorphism oat i L t 1 T | IL p 4} t { Polymor phisno Compile Hme Pun time CEorty BindIne) Clate Binding) 7 Fanch'on Operator Cy en et Reocneo) puerloading OV e loading Ceynamre Binding) fan cy'on Overtoading 3 — cCHce of declor Stonakrey Moe Alifferent of type ts Not alowed, tape - Reaton ing dur Same fancroo with diFFesent + Te Same fancHoo Name Poramefes and + ONealoading of -finch’on Spore cipP bebo. abshachon overloading Ps the Pea. toil be sec with” Pooamekr of o/FP. with df PF. ~eeken and encapswahoo encapsulaboo. eu Abshact peers fo biding dhe ImPlemenfahon details and only the essential ef an object Showing Poakoee Preapswaron eefear fo ecildtn dhe data Cakfarbutes) > the method CRunch’on) that Operate on dus data inh 4 gale Unit Cerass) _ » To Pwr on kihat an object doen rather than how tt does it, 4 do allo@ dipf tm plemen fah'on 8% gat ePind) TokrPace. To Peotect: fue data fiom outside «fo krfaces and misue by Peshiching: dioect ocr fo Same OP dre obvecre Bmponcom, Acheived diush abs pact asses and infer Pace Cohere Some Mehhodo qree Bee AcbeNed trough acess modif- Vike Peivote, pea fected _ Publish ehten Go fel eno and | dectored cordbout 1 Plemo- | noahon. | 7 aecess do crags. Membon, Se a) imp Inkana) daba, cand, “poche. hidden 1 and D infact orth the | -eaposed inkwface - ce 5) Whan an obsect Ps oF e | He doen _Ctnknface) ©) | fecouses ef deRning the facouses oo Sapegarn behaviour without Mmplem| d d__ensming _ o entakion detasls foheqaity oF the obyeck Ps au maintaned+ he y Pri- An absShact elass A crass Peason that encapsys: Shape with an abshact | Hu age a probe and Pao method deauw (). vi get: age O. = What ave C++ acess Speaherc 2 crite down drotr rani Picances- ~— | Acess Speadtfienr :- “clacs dhe daka paiyotc like “The ace “acess § Speciff each ten monnee daha aah be -accegse en only _membirer of same Giecs’ Sn Acees Irewti Ths acheives ta data _bidiing peeperty. _ Speci Freances ! Acese Spectreas help enfaace Cnmpeuation « Which culows crasses Jo hide dnerr infeana data and, peovide Gohmiled Inkrface: 1) Pycapsajap'on +> YF Dota pectecon'- BY Resh’cHing help fofenee EP@P- Sulating acess to Gutain _pointn ofa class, acess: Specrfnn “help Ppeoteck) ts inkyny OF dug class data « RE Cas Cwidi'cal “dota can be made péivate da p&event dive medificab’on by @nyerno) fun cHon- ie > ‘Io heet fance @ppol i Soheet fance is a key Peahre SF OOP, sy acess Spea'feer poy an Fmporjact cole Ip Qopolling boO members ave inhemited ~ with Péofected , RE ex!- base crass member. | Cleow tnkrPace Definaton t+ Publre. member deine te. Qiasses fnkePace , making * Cleor _fo_Osert OF fue class what Rineonaily {S [available to hem. 3) | fuhah ave te IPP. ways do denne membes fancio? ge | Mop 9: chars Save Bx. OR seaen, a ce it ties Dal ag ee 2 Memhes PunctH’on oF GO crass :- © S8efined tnside gq class, + The Rincon defined eostnin dur crass fe usualty cated a3 member fanch’on tn ctt 3 ft ts Colted method “in object t o%ented —_ P&o gramming + The data declawed along caith Some dota type ts cated a3 fen dota memhene oP that Chass , 5 Ext # Inctude < fosheam > Giass Example JL Public ! void olisplay Ort dt! Cont << Indra Rincon cwtthin ftucctass!’ €< Stas endl; es int main OL Example ob] 5 ohy. display Oi tt lp Holine RincHion Wfthin te class | | resknn 05 5 2) Ockined oufside fer crags» The member -Rinewon Fs dectoved insrde fu Class bok defined o)P of it Using: Jer scope — Resolubon Operafom \', BAY a oe = db foctude < ios feam> : free -etags Pxarpie cae pentane Publre § or Nord at'splay C21 Mf Deetorahbo 4 memeren Rut ao : P DeFiniah'on oF Membes Runch’oo suse fue tess word PRLS aisplay OL SHE Cout 2<" Runcnion defined SIP tue ctoss! 4X statis endls ae fod main OL Example obj 5 obs. display O+% If o}p. Rinaren defined —olp_ tee class | fefurn 0) Weite Crt code that defines a cass and deaod and array of Object do drat crags st incude . SaESE Mae ee ee ee + PINabe Using namespace stay N) @eFine a crass Catted. 0 student”! Class Shident § shing name > fotagqe 5 tnt Ta } plublre 3 OPaut Gn Spuctor student O 1 name =" Unknown" 5 age= 03 j td = 03 Me Poram ajeriged Gnsphucpor Student Csteing 9, Inka, ‘ot}) TY member fancr'oo fo atsplay shident detalis Void crsplay © Gnst fy out *<" Mame 1% << pame <4”, Age 1” 45 : age 24", .. UPL) 2e td ZC ents %3 isk mao OL | I] Oeclored an aeray oP Student obyede, student student [3] = { { Shudent C'Sumit 18 Te), Btudene (" Yogesh’! 21, 122) Shadent C" chaifanug’”, 19, 193) ty Leep through da array and display deta'is . fe Cint feo, i [+ doline fUnction s. The Tntine. funct’on fs a Rupction Wh Code fs @pred in Place oF each Rincon cel, Tur | foline SpeciBenn drat dus Gmpiler Should insert du Gmpiche body af finchon *m eveay Bntent where dus Rincon ts used. HE toctude Using name Space ods N Glass deforhon RE tounge Siass faransie 1 pelyobe . Flow base } Feat bersht ; i st) Senshucer doi initiiixe da pase G haght DHMH] fe base >} height Public + Ttiansle Coals, Rear ae - base Ch) Cage = J doune Panevon fo cloietate For mea of dur }efangle faline Float anea 0 Ff | ackan Cost base + beloht )* Z oe [3 2 1D Rncion do Vsplay fur mea. ne Noid display Prrea 0 F ie tout <2" The orea OF the feangie fs +” ae meq 0) << CNdly 3 43 fot mao O FL I] Create an object oF Hue Torangle Class) oat, base , berght 5 Gout > base + Gout <<" nkr dur herght oP fee dvangle i" Sin >? hefshts forangle fnangie Chase , height)! 1} Gan yea drspray Arveq functon sHerangie _- display fread) + | teen 05

You might also like