100% found this document useful (1 vote)
165 views

Oop-End-Sem-Full-Oop - Proper Decode

Decode

Uploaded by

deahbhaky
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
165 views

Oop-End-Sem-Full-Oop - Proper Decode

Decode

Uploaded by

deahbhaky
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 48
Los uv toa 00 eS roo Chapter - 3 Polymorphism (3 - 1) to (3 - 23) 3.1 Introduction to Polymorphism 3-1 ade 2. 3.2 Types of Polymorphism 3.3 Concept of Operator Overloading........ 3.4 Type Casting 3.5 Pitfalls of Operator Overloading and Conversion...... 3.6 Explicit and Mutable Keywords....... 3.7 Function Overloading... eee (vii) 3.8 Runtime Polymorphism. 3.9 Pointers to Base Class. 3.10 Virtual Function and its Significance In C#4 su 3.11 Pure Virtual Function and Virtual Table... 3.12 Virtual Destructor. 3.13 Abstract Base Class. Chapter-4 Files and Streams (4-1) to (4-14) 4.1 Streams and Files. Aad 4.2 Stream Classes. 43. Stream Errors. ssn 4.4 Disk File I/O with Streams... 45 File Pointers... 4.6 Error Handling in File YO.. 4.7 File 1/0 with Member Functions.. 4.8 Overloading Extraction and Insertion Operator. 4.9 Memory as a Stream Object. 4.10 Command-line Arguments 4.11 Printer Output nen i) Chapter-5 Exception Handling and Templates 5 5 5 5 (5-1) to (5 - 24) 1 Error Handling Techniques S-1 2 Simple Exception Handling... Se1 3 Divide by Zero. soo 5-3 4 Multiple Catching... 5-4 5 Re-throwing an Exception 5-6 6 Exception Specifications. 5-8 7. User Defined Exceptions . 5-8 8 Processing Unexpected Exceptions... S11 Constructor, Destructor and Exception Handling 5-12 10. Exception and Inheritance 5-13 1. Introduction to Templates. 5-13 12 The Power of Template: 5-14 13 Function Template ... 14 Overloading Function Templates 5 5 Class Template. eraay 5-16 16 Template Arguments. 5.17 Class Template and Nontype Parameters 5-19 18 Templateand Friends. 3 Generic Functions. 7 5 20. The Typename and Export Keywords. 3.3) Chapter-6 Standard Template Library (6 - 1) to (6 - 20) 6.1 Introduction to STL 6-1 6.2 STL Components... 6.3. Sequence Container: 6.4 Associative Container... 6.5 Container Adapter. 6.6 Algorithms: 6.7 Set Operations. 6.8 Heap Sort... 6.9 Iterators - Input, Output, Forward, Bidirectional ‘and Random Access 6.10 Object Oriented Programming - A Road Map to Future ... ‘Solved Model Question Paper (M- 1) to (M-2) Solved SPPU Question Paper (S- 1) to (S-6) Unie ut] r | | 3 Polymorphism 3.1 : Introduction to Polymorphism Q.1 What is Polymorphism ? ‘Ans. « Polymorphism means imany forms. It is one of the important features of OOP. + Polymorphism is basically an ability to create a variable, a function, or an object that has more than one form. +The primary goal of polymorphism is an ability of the object. of Afferent types to respond to methods and data values by using the same Q.2 Differentiate between inheritance and Polymorphism. ‘Ans. : some of the properties and methods of base class can be derived by the derived clas. ‘Various types of inheritance can be single inheritance, multiple inheritance, multilevel inheritance and hybrid inheritance. @-1) | Object rented Programing 9-2 a i ied object. For example - we can creste vec clay and 3.2: Types of Polymorphism] et Pe can Paro 2.3 What are the types of Polymorph vector vended fom ane epee nd Function Ovraaing 1+ Toe rntne polymarphis i implemented sng vial fens cout ca Th Adon of Te vctoe i* ‘Amt + Dus to operator overloading, an operstor will not be limited iat ane ate ee SS rine | Sr Tenure apne “ior Ergnerng hc Ort Premming 3-18 2. Te opertorovading speed ays, Bence it RD Toes cme ty al 4 Thee ae some opts that can not be overouded. Fer ‘Tom t= 10; (nor convene fom int to clas ie “Te vita eyo is preceded 1 the fncton name. Tha wing Yay fincins we can bie coe strict, mule fncoas perma (toes tk. Thi frei called polymorphs. Fer mpl Rati ropa in Q21 21 Comlder an example of bosk shop shich salle book ‘idee apen Thee fro cases rented from the bse as ‘hit Sia "The dia car tes commend ate membre Sch aing Sent of aos bak td pe tha te ayy ‘ie tn’ tope Ech cline wil ave teonberfmcton sc eto ant “howd bn the Soe atte, ate, mentors eed esa ‘met tincbo wate aa wench tate be ‘ Sp El econ tne q ime St die ties iy poten tos es = fae ‘os ee pin t pe Teal Opens, eco cesta Hae he >>, Sen Hee th potion: ee emt vid sop « =__— = Tif Engage cso Prepinmig 6 Fn Sinan fe The Sample it es heady ete wih edn er nl pose ig ele sve or oan 1 45 FieFomer | nes ashe at ie rected re! Lg ee pee pe pert ee eee se means gt ponte of sper acon i aig of ed vey means ge pointer of pci ation fr wig of sr. oy One Promaning 4-18 Fad nan ect Orned Proprenming 4-9 lesa rng gut << ‘Reading the contents fom ha te w sae etp SEES my ot ete ect ney sana) hee a irene G13 Explain the concept of file pointers. 5a (SPPU + Dec-19, Warts ¢) : — dws Rete Qi agi 0 cor << Cn ot a om nr Mding ‘46 : Error Handling in File 1/0 exit , eet = i) < MM) ec 216 wate « C+ program to peform err handing wth eae oS a == Span sake epee rer Sayan 71220304080 ‘conan a= ut << "Witing tho conten tothe en SerENcar Mamayacstayt/erng ‘aay oa The st fr creating sac meray bist fntratronen_Objoctlame(catabter nt Pue) 7 emo ‘ to~ 10; har name] = “Ras har Data SEZI;/Daea Bs for sey SA — eer =a ec onmetrepemnig Fasting, | to car << "le Mane wager, a mc Benes ee py =. == : eee mame" we aa “iecrosm io fle, Poa in Sle.opent axgvitl Semwenereanw Soren ea ees paren me meee ee an tent mane ene] ari One a eet wee mca fechas G21 Enplata how C++ code te eed to snd the extyat te se enter OEY aaah ease haa oes ne tpt = oe ‘te formamed ouput. Soe en ee a —faneaden ere noes a The SEIS) is the seme of Se progr, or an capty sing if the mame ‘umng namespace std: (= ct sulle: After Gt, cvery clement number less than ange is ‘main <<, GG ee ee S56 re Fa 2 tetanic ato st ee co ‘printer << \x0C; //formfsed to eject Pag® =< Fama = manne fee ‘et mali are, cr ag} ) age te 2) 5 BromtonHnding and Tply | gat OHeedPosomning 3-6 cout << “Brcaption or number hana * << for etring a nando: Value to emer 38 When do we rethrow an exception ? Exlan rogram,the statement void £9 throw(intdouble) the function fn exception of types Integer cr double. If i throws an, ‘cout "inna the catch statement of mind 5 7 1 User defined exception 6 a kind of exception defied by the ost of the exceptions that we need fo bande in C++ are of clas SS Sat “Kiar for Engineering Sidon Object Oriented Programming 6-14 Exception nding od plats 5.12 : The Power of Templates ox ‘Shentance: Kae! Tis possible wo throw the object of derived last as ‘har case the exception handler wil check - who ithe bade class on F mG ase D pubic B F Ips in generating igh performance object code ay 7 Function Tem) oe Function Template ‘ What to netion template 7 oa ‘Ane? To perform identa! spertion for each (ype of dat compactly vy snd conveniently, the fincton templates are ured. One ean write a siagle { thaow a: } ‘ction template definion. Based on the argument Spex provided (can (Bob) calls 10 the fenton, the compiler automatiealy instantiates separate a object code fncions to handle each ype of call appropnatey unston templates are implemented ike regular fnctions, excep they ae prefixed withthe keyword template empiates allow the rewailiy of the code, There are two templates - 1. Punetion template 2. Cts template ‘5.5: Class Template (22% what i clase template? ‘Ana: Uning clase tonpne we can Wie nls whose member 1 ‘emplne parameters 8 ps. Tear ago a = 5-20 api Handing and Fp 5:19 Beton ann nd Tempe + loming post valves ae nt allowed as tempate parameters +The Nonype template parmetes provide the ably to past & ‘constant expreion at comple ine, For ease code cionsean> ‘sig nemeepace t freecT> carn template int (> cla /otagal expeeson Saari meen ang . ica acta 5:22 __Expin Mending ond Tena a c 7 eR ee ee en = a ee , oe =] , : o pie ; ae : tn a = (381278300853 etna Se pera ee = eee ' = 19 : Generic Functions : seam Seer teen ne seme ne ts her mm aer ee coe tore a ‘hog: = When the clan loge can be peered then it comes elcome Se Se msig rie : i ES aor —s “A Gui for Fagering St = jt Ont repenming 5-38 Eero landing Tn, 28 What le template ? White & program to handle addin o ‘fe umber wing template irre he ‘Ans: Refer Q21 and Q27, 5.20 : The Typename and Export Keywords 029 Esplan the pename and export keywords "pename : The keyword spename cn be wed in piece of eam lempateparler it. Han be wed in template decaaton 1 ‘enon template ca be replced by = = es fone {tne vt | ===) 21 What ie sti? ‘Ans: The Sunde! Tempine Litray (STL) is collection of vy structured generic C+ clases (templates) and finctons. Basically $m consists thee base compooens - 1. Container 2 Algortas 3, Reo 62 : STL Components {22 Explain the terms ~ Container, algorthme and iterators ‘Ans. : Container; The coninr it» Cleon of ejects of diet ‘apes. These objects soe the i erator: The iterators ae basicly objects but somtimes they cn be pointes and hence iene Algorithm : The algorims are wed to process the cont of he ‘= Dusher)//puahg the lament onto the wack cou 213 Waite «C44 implementation of pelorty queue operations Sing STL apuab(ten)/fnering the ent onto the quvve cout << Nn Nam i nerd rote: came 2: tm = patos: ‘PROr/-Dleting eames rom queue = _ —_ "Eger ence algoritims - These algcrihme 0 not modify the conten ofthe comaier as they work. For instance court) wil eum Poctate > ockde calgon G30 Esplin how sorting alerts can be ed to sor the lt of ee ‘lemenes axing ST” : ‘st main ‘Ans. : Following progam can be wed 0 we the son uncon provided by the STL sno a = {102004050}: srechade ee rent = moa ‘Fochude /eeyword ago tached 10.20.2040. defo SIZE 10 cout << i Using minas10,20,2040.50) sae cout <2 The minimum laminae =" << era ae: cout << (The mast element =" << reel ncn um ‘ns stem aay SCE > (ut < <"How Many Blmsects You Want to Bota” G22 Wote « C++ progam tm STL to nd out anima of to ea>>e, Sime fot Limi arey +n: /etung te range or sorting Ana (cout <<"Entr Tow Nuon ee feu noren sey [rempdenearee ‘ ing namespace md: cop >a: co 7 : ‘ ~~ nen ‘cout << " man20.0)=* << ma, 105 these apes ow set operons. Give the Implementan ‘hese operations aelog STI. ae union, intention Arne ng ‘Ans. : Various set epciion A MMin heap = {in 4 tee in which vale of cach node is 10 value ofits chiles nodes rental For example : Fig. 242 Min heap We can consruct heap wi . “ne ig top down approach wih repeated inser 225 Give C++ implementation of heap srt using STL. TM Oe, Has 7 ‘make_beapyy.begin0, v.endQ)/males the heap trom range of Meterwcta cout << “nln The rot of max heap : "<< vont) << "wi rr garg So 69: Kerators - Input, Output, Forward, Bidirectional and Random Access 1.26 What le erator ? Explants types. EF (70: Dotz2 Hans 4) ‘Ant. Th erator ace wed to averse the contents of container. There ane five pps of err ertor Description Random woes lent can be ure or retin anon ‘s+ nena cle for robe progamming Decne robotes feoue ah perme cde For banding low eel mete eouling 5-2 Sead Uaneiy Qnenton Paper tic Ord rpomming__5-3_Soud Unb Quon Paper OR 82 4) Explain he concept of method / fiction overriding along ith examples. What is operator overloading in obmorphism ? Write the program 10 overload peratr ‘tet tm op rb roth of (eter similar Q3 of Chapter - 3) ©) What i viral frcion and wee ? How we cam access 2) rite @ program that remone the sce in bytes of @ Program entered 0 th command line awesoiettheremnt 8:4 sd te Qe rye > seca tatopetaot {atseeg oan, out << inti) << ond, , ©) What is 0 stream ? Wee 2 program t ihre the stream errors (Refer QS of Chapter = 4) ry oR 4 a) What 16 a fle mode ? Describe the varios fle mode options avalable, (Reter Q27 of Chapter -4) 4) 8 0) Whar & need of exception handing ? Explain npr of exception Refer Q2 of Chapter - 5) “ b) What is template ? Write program to hole oon of 00 numbers “1 au. ciao ‘wg namegpace a Sr = Ten tana ae te Cred Pring Se nvartyQuon Paper oman ‘at mag) ‘ ont Saat ee 1) List and explain four common examples of exceptions Haemost m 9 ht Arce Stent epee ant fn template in Guan 017 oa 03 f Chapter - §) >) rite a fncion template for finding the minimum value cena i no ee O19 ot Cater) ©) What are wser-dened exceptions ? Explain with witable example eter Q.10 of Chapter - 5) m 7 4) List and explain diferent npes of terators tn STL. (Refer 0.26 of Cuapter- 6) * = oy “Fe ngwtg Sane steed egrnming _ $6 Sehed Cty usin Pig 1), What i tack ? How 8 plemented in ST. (Reter Q.12 of Chapter - 6) ” 4) Use minim 8 fictions of Dgue STL. Write 2 program to explain te same. (fer Q6 of Chapter =) oR as +) Elaborate adantages and disadvantages of LIST 4 1. As LIST. is sequential container, we have to waver sequentially hence searching is in-eicient. 1b) What i meant by associative container? State and explain the pes, (Refer Q-7 and Q.8 of Chapter - 6)16 2) Use minimum 8 factions of vector STL. Writ a program to explain the same, Refer QS of Chapter -6) END ——— = “Tear gnoe ts

You might also like