0% found this document useful (0 votes)
100 views

C++ Complete Notes

Uploaded by

AR OFFICIAL
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)
100 views

C++ Complete Notes

Uploaded by

AR OFFICIAL
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/ 84
Ce co eOet op's Stu eneued {> Snheutiance and putoceatucat J when m yl poy, eG Enca pulation cre ls eapeatt of «! tengangs fach and eve valid statement In 't! cs auo vata “in C. 4 Crt fs oops do “HS duppbtel Ww Entapuledion (Gi). Polymotephyer (i) Qnreudtrance “an 4 C++ Ada a a class, C++ Ty not pune oop. Migxation m C to ctt 0? is vay powerful and capable aap i nicky ue suiquisud to mniguoste fom CBS C to cet way 4a al peing Fncweased the compuerio a h agubty ahwk cata. but them ame dome boson Uy Bike $ ps while the sive Frond, Ceara weuulig Ther que not md Scanned with CamScanner oT Snt bat, Sint oltp; 5 tet wht} use yy) by. clepe = 000 ; bi bag = bis bat by dep; by bar = br bat br bat-0 ; . ic Bind coos (fan) ® 6 e ® Encaputation ¢ i @ technique 19 eich we bi ‘ and cate (van) within ingle erry au Sad ji (ide the ‘Lacatt ha ee - t 4 4 euiide musule, J clas wth Ae nelp —ouy lak i wake jaar ct) Folymexp ms hi » ly + moulp v Me mw ple phases ° Se iy a techakgue which & pase on the concept 4 aad (24) See pani ated add (511d). Gxample ? we can Ceeeate multiple - + Same nome ast (6 ,1,4/2) i sy ute att ae abead Potymouphysra 6. ae . ongie namic pie ime "4 mh 1 o untime, monn nue [evirtuat per Conte pventoadtiag op Ande ovouona vg Scanned with CamScanner hee °, , 5 teh oy baded on de Coupe dit) Gnnowktanee+ fe 4 tecnalopte wihich i“ ( fi) Inhawtan’’ 4 : gn this one cass cr fous 4 CUD Shor class Ond Can add ves ash pate: The clas which ake pour & coud dud ved (oss and fom which dt tare W Cod bak dass, u C a Woagll < ado. > & fos streamhy PEC Heto)5 cout é¢ "Helos ft (hd ay , / Cour comme “impur (ket Ss & tuation ‘opt. ce nsuetion Oph ae Class? ty quoup af bot of vautanle ant function ator Sih per g con cept ut éneaputesion- , WD To ouante loss ue wet kegword elas Gi) Olay declare bere main,cy and at sre ere seus Wi) gr Clash we con dectare aliypuent diffeenr he 4 both ae fen td = ‘membs’ yontable and —membi\ an CaM eo = membea Loess + 4 * 7 cleus oye Here (y. Scanned with CamScanner - Cv) to access 4 the memb ue v dod “gfe Vani a set oe 4 dass use seq, ad m w To aoceys au bg ; the member of clays we 0g, Clay vosolsle Oeirg objéet aud hem dt aoeess i ono we wud © Alek Spucatye. es Chow name vortable j MN. ee y cfr aac thee class Pr class ; \ x 7 int Og vid fun tnt oye) int 40} 4 ee : ‘eout << "Hello Ys roid show ©) yy ¥ y ¥ cour £6 Ql ecsaly data. icing ' Y ee ts a technique lth the heip we can make Saft 1 ms utkide mmicuse. foc 2 ue used boneept 4 aos ACCESS _Speciftin- Access specipixr : ee dame, et mows wheel U euts te dpecified tho behaviout (scope 4 class membux means can qecess and ushut not. Sed tn euraig enseg a | thy we ence! deiued ounsice hank fullvote 1 x is Pueotected we _ x public ee al Scanned with CamScanner dow ABC Nectiae pauverte > int Preotected 5 in by Public int C5 void pg tout 2605 tout 22d; Cour 24C5 ¥: ” ; yoid mail) ra ABC Qu} Op a= 1X cyeb 2 25X ane = 3 y Class ABC % Tne Mye> > y aio inlaid Int sateY wt tuunot Triblie fy class MVe we cued whe i we want Class ABC $n crt, dle} ate Oars vn e) hulle? int sal} Public; void ot O x courdd "enter age rsal"y cin >> age >? Bab} y vojd Show) x Cout ee age CM} y » ord main) x ABC O15 Ar) Or age= 10 ra x pot aces Oy gal=lovo psuvocte An Gat OF ar show U5 A. show 0) y peeps fy peuvadte, fy lous on He tue toncept 4 eg LUO au 4 my. ceelaraty Scanned with CamScanner Consteuctor | i ; ara t “ Smmila, 4 iw name Pee ad . wi Cais name. but have no weet type | class Mave and “tis cated automatfcntiy, ushen objet ty is cueated. Class ABC t Tat ages tnt sat; public! , { ape () ‘ e=Qy jah = Us vetd sk Cou <<""Enien age sal"; Cfn yy agerraaty y gees void Showl) & feu age econ % wid maind one a4 ABC a ,ar5 cm) aseUs s so a. show, 5 S& Ge show, 2 q > Desi wm og Scanned with CamScanner it marti ple col thebe paseamete sand. 4 Consructor ONO ——— gt ts a technique which spew turer Win ingle class’ bur they hose coli tuuctor is Caued ushteh pe 4 on the stime 4 conatwu cho canting pawameter: we pars class ABC x ' Yat oye Snr sats Public + ape 0) x ard sal= 4} \o aac Cint a) ot SUL =S00 5 » Roe (int a,“int b) — Sal = by ABC (Chax th) v age = 1b Sat = [oov' Y Void Set () Cut ce" ent -tin y : » » oye 2réal, Wid show esas ified i) we Wank wt can. wate, aue diy. th 4 Caut <2 gece Sats cess % Void mein’) x ¥ AOC ailS;6)j——? fd Be a5, ——»> fB ARC a3t8y ) one, rs a, ~~ g ase} $ SW “Eg ay. shows §» §00 , ¥ Scanned with CamScanner a Pb. © aueelo adi . , eA St Wa sechntque in ushteh we can an mustsrple da vame name. i d but they, cau offen “in shin para \ met. wh Poss lon ahese June u caut whieh » ype 4 pow the time of the Jun cautt ef bos Class BC 2 ¥ ZL Public? s “ Void Showl) y S cout 22"-7eUo uns _¥ Void show Cink a) x . a a “cout <2 one Wnrkeas, noid show Cint 0, wet b) * out ze awa incveca yéb> ; ep + . See 3 Void main 0) Y WBC) Qs show 6516); ; 4wo mis 6 | é Q show l); sew fun Or show (6); y one funy . ‘d Scanned with CamScanner sine je ee Fun ctton y f } Consbu UK w function names Neva FAME) Cons-rurchs mame is alw: as class name: » Same as char name, ‘v (il) function howe a Het Wpe ea 4 2 avatue a4 not, qi) functibu Is et, Wi) conatuctor js used gene le (") Grburcior have no Jue yet: wil Jo aus tet un ha sup do Lnitive claw mv. (WW) %o uae fun we L109. 40 UY) dru cau. omtomatr' whin cou dt, Ha object afta We fate cunoted- §nine peste” Needs void show) ofp Cour wHellol; : : ; . . ’ void main) i s Rist, fs eho WO) hae show Oj : Showl LD i ys , ’ Jona uanen mesial fu tattiag fa perform Jot of aysien dine Bs wy caw ane po m easels a jie cot pusutin ane fae once qf inte Scanned with CamScanner ya Guuin£ Function iy Savin 4 we cunt, a fur as Yneuine , Lot a ta Him } ' 0 eeu and pacpoess | en, as in thir a ol, functfon pa Og Hlu kame theme m shore dun i y ‘ it i ° b To uate a fun ae wx wai © nine Kegoos “fs ait, 1 dating ahd how . \ ; cour Void Shot) meme au fer tex We Wed Conceep of Ried fon Red 0 Pe ae Cacefe fon A Ried 5 Aen ih ip Capalle to Aty py Pructe Mewber a tow clay Uh? Aedebion Vs Bxorolle fy fon. for exp uo Wort ty Cronpe PUNY ext Cid, Fy ts med odd A dip Cay PAuste Menlo. Genny Te iy Nop boistsle hap °p OS ExPhah Wort arg on : Re los Med Ry bu to» fey ure Pen FoI! wl ug Condi" oy te GO) Declan tw Rw Pro fo , fu Hypo Mi ~~ day ch Py _ Punto uw. ay a 4 ean Red bof uf Scanned with CamScanner a Ahed befre ap e gw body OS Bn ordamay Rn di) wor aw fe fred Ru wo Med wot obj Arey Gu direct Prot Py —_ oe Chou ; Co Choy fac tae odd (Ame 4, tar fi) A, — 4 en feat) 9p CU secnqidajs + FRR, Vode 6) riggs ibs Syed tak ood (2 MODE | ¥ vad Nol) Chay Pax 4 cK 4 — ary be Pup — beers 2 Rule: par py Pay 0) NE easel 4 : nat Pub ne odd Cat y Jen ak Job | cdot ( Hor Por ) Chak & ae aioe, Cant 20q,- baby ‘ wet Cay ¢ fd; 5 J 5 . fread uord — Swop (MDC, Pax): 7) Scanned with CamScanner Fotend_class As dake wend fun if we want we (an Alo Uuate a Ua | a faiend ushen we Ceeate a Cay as pr’ Hu Copaigle, to allows Wu pstivete member qe end class class ABC a tot at (nt sat; Public! Fyufend chase PQ® 5 y Class pQ® public > void show (ABC ad x Cour <é Ar YESS 3 sany ¥ ‘Now accelible 5 be cue {ested void main) L | ¥ occ, mem ts vautabte aufable 4 utotic Then ont class memb% V a ple, is cuted fone ott aa ih we declawe the one to lass member yatu' objects hich 18 hasable hy ae . i ie 7 ied one & mo) sd Rl ju au aad wm ie , Clay ABC x wtodic ink age) was publle « bei, dot U Vout << Ente age nal) Scanned with CamScanner cn SP age Psa, y wig showl) a ra y s Int ABC H: ges Void main ALC a G aut O , a ovat Oo Teg a, -showl)), q asst) g se as.shows g so Y sStatec_fun cuien seemed! we want tue ut aces fhe fun as stasic +h ew dome ; (i) state Y" Can anys ced fi) we vcauite Lome keyyoot bias points aa ny can declaw 2 n alse 4 L we suguitud fo atts mvs anmetty « fn cau etad fun we ned not C) Ulawnane $% pannanct Class ABC d gut nr YO Mast vine wel; Puulslic + aro void showl) - we ages ¥ vm Be “A mee i dat) : Scanned with CamScanner oid main ¢ . apcs; Show, ¥ ; i 7 Qh How we yo know how many ob. 4 dass is Uuared | . Class 813 © oe . , Stoue ur Count, yBcU unt = count +1; . Cour <<" no, 4 oly =" ez lount; ¥ & ing ABC? Count; Voll mainc) ac a, “/ho. o obj MBC as 51/0 of oby 2 ABC 03. Re // no. a oty-3 Scanned with CamScanner Rf Nowelle . 1S A New thao / Hi re GY the vaxrsyo Meo No bepecate Meoy i¢ able to fe aay SOR po Sow Nowoy Foes af Adel Vor, To dcroke of wy QD bop fw of derlerohkay Tey if why New Moro yf MAp So Hf wo g o ‘ Node Choger Tn wr Rofheb in Gy ahsS wtf Le Mode Aoger Jn Achsl py Qn Ref Uarel(e om te ico Q =o; Prades Sub af = a co a wont A= q +o; Pef Gaup ce Pj] 20 Petr; Gut seq; 28 ot Oy Ts a ype gf Rm eat UR. abe P24 U2 to Pw fo Redwol fey uve RY Pel Uormate Lp ww Vow Mef Uarryle Pe, O44 tow Meno gf thf Uaruils to FF ME Made Cheer Sy ib Py fo auch} fo thy tq. fe bomBhRoaf uhorus umat Ug Ulu, Not dAtrh patible | Scanned with CamScanner vad Sseuop. Cfug 2f) fot 0 9/ Vd wo, OC) 4 Tek a, eo) be 38; Borer 41 $Y, Caub “a NON- Petemdsae | Podeyp “he PMaueds re nme Lofy Cons frvor val Scanned with CamScanner eras a: ST x 9 hh MO wa alyo dou eam 4 Ay tas, Ce ae by Ayntoujye Cont fe v notes ay Meo aWeatian fn eh ve dhyptonic (> Nom-patowhy or dafort Conth any woe fn ubfch Uley Wo cdelory fo ra Const owe Nok SepuRed fry argu in ARC C) 4 & | | (1) Patomehe Or aagu, Grit aw tore | fn which Who ae | clean q Gut wo alo sepufred ove Potowala fn show FETS frewoky tbe. Ane Link a) Pri ( Pra PD | 4 x 3 Pot (ur at, inp h) A 5 Ss | | wo Mower pay Clay oh polouet fh pasomeh 4 « Scanned with CamScanner ay Copy Gn spor oh wo won fo . hoop v0 a9 Paik re hy own Clay olay w oh Chay Aro hor ob tum Pau aR wide Lay ef yop by vel % Te rs Med boty Gushtor thera I Ww pay up wit by Wf “ron qo tel ip we Poe Sere Chay Frohros ob} lat WO Nof Abad fo Garfe 05) bak Wwe bot + Tribe ak- So wwe fay ub with by RY berare fn Cow of fef Mo - Moo Sepecase ob) 1 Caste erly Mao Nowe yf | Sebosp = lee ‘Scanned with CamScanner clos anc 4 Pup ger Yop Caf, fulre : vad ser) we \\> vad Sia aw c) 4 sot eon ed Aree c) A “ges. eon! 3 belur 7 2 pac Ciud &) 1 ~~ oH =H $l > Sco 9 ani (hd a, (AY Sage > a; Bef > 2° 5 7 Ani ( Wo A) 4 Fe = 1; Fef sirvo} y 7 ped © 3; ved BIC ARC ANC pa Ane boc yf? " Cory Gah Pel; Ko , td al 56), Gaz a0 fe 6; as Cas); aQvinewty © 6 ay INA), IY Og. nwi7s € Se aye Wh, to 100 Gs-Iney@ IY g x 4 Scanned with CamScanner Eee Hap AeYrrhor Pe Si NM Lon sto Pon Dee of dey js Sows co Ns lout Arome No Petty pe Pro th Colted Quo mofcodty lou ok of Uoy Pt dtyray OF goaut 9 wih sepe Te curd Gikujoy- oY Gal Mow We Wr 1 Sign before ah. Chow, ARC 4 pyre: ; Ane oC) val oe (=F dans Le PA Gat’, 7 . uw foe CO) sf » Gout “cp Nduf", : 4 2 vad wa U ob Coofe fo A AD a Gar col nye , OY” TES go au fro C604 Scanned with CamScanner _— |= 4564: ei yne class 6b] ai fun cuutay " Passi pan ae 1 vos aste 4 oe ane i can pass ae ¢ simp a comple cass olyert Ge nen we pas sojece © wad anoth eH> ary oh naturn to" fun. we Saga a eS tals can eoatty | ave Public : wid st Xcouk Le NOHO sue Fig tin >> sual sing 5 woid 8how 0 * ut x dual cel y complex aad Ceomplex 9 y complex t 5 tepmal = gual ¢ real timp = Ying. + cogs etm ti y ¥ oid maine) . comptes Cus 5 aserO) OSU Oy O37 ey-add CO) $3 ehowlse Scanned with CamScanner - cass. ORY Sa CC EIES’'~S: Of A Gueate a fun add which add 2 ott: { ; | Clase Contain pat 4 mg ah memb Ot he Class culo 4 tnt {ects - \ at ‘inch; Public: Void act () ; bs 3 Cout <<" Enter ye yinch" Gin 9 feat sztach , y void show () een << jet <2 inch), ¥ . dite adda d) x aut E5 {feet = feek td- feet} teinch = inch + d-inch) while Ut-ineh p=/2) “ inch = teinch-12; b fertt+; Niet dryads 5 grou 8 Hd dry 9 0 daz dada td2)) . dg. shod U) - y Scanned with CamScanner fl Ouate o On EE OLIUE AR tM OHOAAL, | ULI Ee Clots seat onal N F int pm tne num; Public: wid se om ee Mentos mum deus"; tin >) num) drum 5 ¥ ° Void showl) v ‘ Cettt Xe Bete SE te. Cour <é num <& ana; V2 Rau'onat add ( Rationat R) q Rational = ty y 4. hum = num eRedrum + daum % Rinums = ubuply fun, tednums AMM # Recnum | pongo mul (Rational Rg) dutum t) y Roo na. ty, » denum > rum # Renn s, Yoid mainU tednum > dnum yp Rerum 5 snp Riser R33 er hy du 0); Y Ra.ttt (5 Rg = Ri tubl ba) Ry = Riad CR} Ra = Ri RA put (RZ) pre nets Rye Realy (Re) Scanned with CamScanner EEF gy wih. Fl Guate a fun mut which moutiply 2° cy smut CO) + (atid) x cert) + gc-bd + ibe bad) Tomplex mul (complex 0 XY Complex t 5 7 . nl s % ‘ teuural =Creat # creat + img + cing If teimg. = img KC ped + tual ¥ cvimy, ‘ we IT ct) » divide 2 complex no. complex div Ctomplex o 4 a compte, by , 5 I n coimg # CH te num= (reat ¥ Creo ting w ering) / (c-seak # cduat + 4 jy Conment ¥ cmeae + een x c-ing) 4% tdnum = tig » Cauat - weal ety) craum ty \ in a+b. c-td , a aid Cid Scanned with CamScanner Ce 2 fin add Ghidtn cad 2 Moup Clonttashary Chay Sho a * Chan Now C os); fu lve vere det) 4 2 Comp Cor-plee odd (@pts o) 4 G-pus 4; to veep = (MG) ref + © reef LTE > typ TP Coley. ast; o Scanned with CamScanner vat TAY Cxople Oe G4 fill EAPlere aw Lomef}- ¥g py bowere Yo toy Exp oS ae i fro new) Curent} / Cooling os wihag Ger) bap We Gon Alek GOP are hos. co de RU Explore th Lowetp wo Wed awoke exp Yh GhPUd a Aw. Not QULY te Menbese lurve 04) but ut Garp 65) Clay ADC ‘ ° It FR Rales : Verd Get C) ued Show 3 | {0 Gap LC ENE ORS Coup sae) ey t, 5 vob OF); x bad WU © go. A Ay Sek > Qg- HU, Qg- UW G-paxe CE J. 2 Qa. show CL; _— Scanned with CamScanner Anhenfiance Tp hs fla posed 0? _ kw technique whic & bf code Meuaebriity 7 pom 4. dn ants one claus Ca acces ‘abut another Wass and aad dy oun wn a * ue pnp The clos ushich = take feo’ S . . + take joo deuived class and yuo hich dt known a4 e clots» SnheurHnce in srirgoen? bs matty categerd sed in jelouseg. anged! 7) gingle? in which dhedx anc only bare and only ene 4 ut dtutved > i N 4 aE Ci i + (i) mustttenet $ ane th eet ww ushich ane clara w del anethuc and wouR A baer 4% a ananer- pa, J — Scanned with CamScanner Oe a yi Heateal innend¥ance § OH thate iy aphisn mous “ham fav ene clasts U dutived yoo one base / Class. cot ' \ B (iv) Muucttple Tinhewitance ? aue ahsie in ashich a Chass ctetdved ff ws) wey Ww) Hybudd ‘inhaivance ; is combination, tf any “koe yee 4 ih ewan ce. yom moug than one baie elas inheuttance Wwe can cueate g type q clays - To achieve wultten as ai! oudinasi cla. W) Bose Cass: & Is (Vaedved class: To wslte olemivecl dare we ud { is ng Syaay 2 iT Q clas deived aces Base class tleus name * cul e peat name ¢ 4 of duutved Scanned with CamScanner | Acceeseete Sneudta nce Class ape tne access pedeot base Clots x. apectfitd the slope t ‘ Privates guuiveds “9 Yat a; member (” «, (at oud Bute cted : ‘Thy oe ge” d int b; : fouowlag cate * Public! A nec; W Pulvate F i te 40 Void showl) uw ee i (i) Public Cour ea; wt cout » cad 5 vetd our) { . Cour 2 Ye, j yoid show O v Emploute # show () Cout << Name << AGL 5 ¥ # % " Nold main () d feuon Pry Prset 05 Pr Show); 5 18r x Scanned with CamScanner judeal jnheutance o ene fentoyes elat 7 LZ, fimegs)] [ewe] class employee i int #he.; far esaty Public: ord = sek) t tout <<" ents ene eral’: tin )> END? esaty , J yoid shew O { Cour << 60 ened) € Sal; and casas q 3 vid — Show () t Cour publics void och O J TC ut familys’ att OS cour cer enter naimne age" ein sy name >? Of 5 4 yor! show () ¢ employee show eng qemly «+ show (1, Cour << nama << A9 5 4 ¢ 4; weid — maini) g pewon — pr Preaetcy 2 Pt show); 3 Scanned with CamScanner alas company f chan thax costd ie], ename (10) public: void 3ekO t Cour ce "ENA ¢ompnameé tiny cname stad; vid show) t ut <<" Comp Name"c< cname < ass employee: public ‘int ene; A 2 (at egal) publee ; wid set (2 rmpany ;; cet) mpany: © show! ); emp ne" £< the cet! gm comp ade 'e< cad “onttu ene and esae"s ompadd "} ecendl; company. p sarice oral dendl; *Yeour clans femuy Q) vint nep; public.’ Veid sent) | . Me t = compat publ ish — both have some _ books and eugclfo Cassels membeu , title y pul book no. and pl Hog. thd dope 1 10W we a * causes, Now teeta hldapertia Classes f with and taput fun. bookcass Output Class Chau tele [lo]; tnt putce 5 Publics Void sere) Cour title >> parice 5 yoid show() - Le THE bookne} 4d Ahow 0) bookcass * sghow 0 eput << bookno << endl; gy y } class Cassette 1 public bookcass ' tnt playtime ; public: void set O e bookcass $/ set OF :) ti sine cout <<" Fntew playing Cin >> play time ; void show) bookcass t | Ahow C) cout << play rime << endl 5 y 4; void main book bby Cassette CL by set) cy set 5 br show Oy Cr show C); j elintccaianit Scanned with CamScanner sepa eee he needs I) they He “olthL - 9 n 14 aeeeived class bb jame fun’ in both : Cnc wel want ity cau clay object then tk can diffewent but what happen base CAM easily — pecenuse Name cu dame and deuived Class fou this uu we ff nested credecotiag, ove didleg, Claus Ape dans { Publte: Void -show() ¢ g MEE Helle base"; ) Uass POR ! Public anc i) Public: Y old nd) vt Cout "Hello detived’y bj Yoid = main O Y POR fy Py fan 05 Pi. show ()y 3 : base and n fom dudued @ name aw in both the conupr Scanned with CamScanner Mostend . . y Method veut ling is a Hechnique which — dpeetffed . thebs Cs : t rue sane Nae faneiou ty bot bare and au anu aetind — elas an nnd ut we want to Catt athe function fom aeuived clase — eh}, Uuthich ty Capable, Je call both put it ooo catt —deuived class qe : ti 4 tule Beeaute Same — Name ¢} eerie | base Coss I %y athe Jame Name pineian ‘| dutived- ( Class ABC x Public: yoid show) a Cout ce" Base'y ¥ Class Par: Public ABC Y Public: Vord show() q cout g et ayy per (hy I MULTIPLE _INHERITA AE sus =; » $n tuts fer 6 au base daw — toustieucter fs Colud then deuied es but the Meu mom than one bate clays 4p el baue clas pouteunor call Ist urhich toLutten w inheutante — fyp on ane tine — cheratca’ Clan ddeclanaliby, but — dleatteuetor uw opposite her BC ne u Class par: Public ABC public! aa fublic ’ ue per dor Abc"; x “our cc" uum cer Cour <<" Cons. pe pity. Ms ¢ vu 900 npr aoe ‘Y our ct dessrucrr OF COE test. pen", y Y y yy Scanned with CamScanner lass xyz: public par qo public? ayt \ cut Ce" Conds YE a ryed < uv x op Me cout << dedi: XYZ "5 ’ ouetfuet % ° tongs Pe? void main nc x xyz yr duty 92 y ee rer We know nen befpse hil class tondesenctor — Is d concpucey Is caued can struct called » Also eememb Uc oxpltedr want to pose pause nt class child clas any type 1 base caclar CONSLHL ctor put ih we A bower chid class conateurctor then We can do Lk | u oppelle lass ABC cout <<" basi wo Lat 5 ¢ ¥ Public: noc (cha ch) Apc O) “ cout <<" Base Chak " x tout c<" Base reno"; ues Cinta) cout <" Baus one ints Y ra Cint 0, int b) b y d Scanned with CamScanner “Class pars public abe void main OU Y Publics x Px >Base 7eun x i eo re i Pav tom cout <<" fax zeus > base Leto Par Prl y 4 Wye); Qa feo 10 P¢¥ (int ad - pase TOW courte par one iat pre BC9)) < pax one tt y . ; a pee (int a, Int bs nye Xj < Base CED Cou << "paar “two Tints xye CHO “ee h , Base duo int aqrcleke xyz wl . % >, kyr two et clas xyz ' Public ABC : Bose ene int “Giese nye x38); C .. Public! i xyz one int ti xyz). abc 0) w 8 ’ Cout Class KYZ public pure public abe XQ Public: void show 0) RY a nse ttf. cout 2243 < Hee 1 ns. y 7 ¥ fees am bugil void main © ¢ salutf on { puoblem is 4 with type tay one cope t pase tlass’ membex Fs curated # alt of Le aeubved whe problem ts seosolved fou this wet used concept Us Scanned with CamScanner re Vitugeal base Chadd. we Tanbudt othe class wvivtuatly one copy) 4 qucated fou aut of sthen only base class membeu ts fs dewived. can be shaued v4 deuived ftom detived. qwudte woud which the class feu dhs nitetual beoue ou ate ‘| acces ap ccif ie. on the 4 dudved lass declawation. pt © Clase ABE v A Puro tected 5 int 5 ai io8 w class pat } Public virtual ABC ¢ . y MY astg toss XYR! vistual public ABC af ») we K time virtat wi tuat ag class xyz Public pat Public tee Public: Mold show (d cpu «i, ys Noid main () ¢ b Scanned with CamScanner E fun ction yout Ta need pe 7 peel Dudved 2 how () show) Base ¥) dul dG deyr 025 Reason Pe ddyy a pashow () gase's early pe 4d2 jee Binding pashowl) §} we have aclass from which 2 Class ue and alt contain same name same type fun : ¢ Now ih me Cueate base class snd assign dard and dev? Class addsess. and call same name fun ahen UY always cau base “t tos jun Reason cantly Bindi : et ‘th my own Class have attePbide as child dy clas. potnis ne wien ind oun clas, ember compelation- L ‘e dion Some dleuived , So wy fy caused eauly OO Compile time 6 stove binding. This concept is dlso catted Compile dime eM static pot: mei paime clas base cy Public: void Show) x u cout <<" Base 3 sh class de ty public” Base y! 5 3 , Public + yotd showl) % cout «ll dew t'S yo 3 : » class err, Public Base Public « void Ahowl) § cour de" dey at, y ’ % void maln() Base ¥P; dws dy da 2 dry Scanned with camScanne ner Pe tdu Po show (5 Pe fdry Pr show(); \ | bart Solution tut we want which child sign to class adducts we OU with boue class petnt dit bu there and these clos fur This possible un wht any ay ¢ base cass function « vist is onl c= a/b; we used openatore with wor agind dale ake class obj. | . Ke” at net we buause dh not know . a how do won wh en ded dla: body 20 wy Class —CompLext int uals int fmg: D publics Meld det () 4 ‘ Coub <"enten seal voy’ Cin > weal sy ‘im vated dhe (9 \ Gout << y — Bt 4 tay < my : Scanned with CamScanner operation ot Coompler cy op tinh tach +d+ine! Yap ie vahile C42 Linch 9°17 | | 4 pueat esceal | fi seead 4 Linch = tinch 125 ting feng + colina s ifort +45 neu ty y y suet £5 ’ id maint) 8 ‘ void main complex | Cty C23 C95 dist diy d2yda) sas Mper di set) set (); dy tO} Cy CFCs dg = oi + de; C2 howl); ~ y ovedload *+? opt fou distance 9 uload + for ‘Onol casa class Rational Class. Y Class cid int num; aie fects tr dnum; at ‘inchs Publicz ; eee Noid sek public: ¢ 1 5 Votd eat C) cout << érdey num drum"; x \ io cin Sy num >pdnum; cout e< Mentor Loet “inch; y tin S> feet srinth; void Show) i eOr <énum << daum 5 Void Show) ¢ ¥ Sineh> anes fe spin ch} V. out shawl owt 57 fer pinch 5 Int opecatos + (aise O | fivat 9b; | a: {eet be afer + jpeaeeb? | UUM u | ase | , wetum 0) » wio Finch | Io + aeinchy | by void mala (7 dat diy 2} dywet U5 da» set) 5 ig, Ud = = 42) pacintt “yeas ase | pauercth, WN"; ovstlo ad seormpouut won fou Hattoual Nd. Class Radionat a, int num; Ps int drums ; Public: ‘ votd set O ) ‘ 3 Co u ut <<" Enter num arom! din 3) rum 35 drum, « 7 Scanned with CamScanner == (Rotional e) | : cao a OP 0 ‘ cnum ye R-dnum =? drum + Raum) eu us ef SE een OF y Ki void main) pationel Ro Rr apa OF see OF (Rie =Ro) ova") : & i pacereth else pun, NOY y Ouulo ad, eompanisen t t Hie clouds. (lus time a) int h int om; ink 3; Public : Void set) a. <." Ente, hour munute secod)s a Dh» mys; ! a= b & 3b004 M X60 % le cout << int openator ©? (ume t) x int % a,b; +55 be bb x gbumk pm bots; it (a=>b) Mourn | lve Jem 05 | > void main O x dime to AysdO> fate” t-show); ta tulad Compauivon Les. str . ” Xv , thar name [ie] ; a | public: | void set) " ertec name's cuy name; ) tnt op vuatos = © (sir sD x, i: int a= atcemp (name, $name - Scanned with CamScanner REE’ TSS' OO 4 Ca--0) Aetan else UeKIY 0; y £0 Void main () x SUC Sig 8) 5 Si-set (J; Sr se 0} it (8,= 283) peda, CV ea"')5 else. pau CN"); pent Oyurload epewoto qunctiou TE we oyeuload +he operates big fiend funation shen we. ~ meguised to seemember Bone. peers? (D9n this ease no obj 4s suege pe cattng (DAT objet pass ax augu, : a Oventoad ry) for Pompe’ yy uainy fuclend apie oparaby + fiend Comp thers , t compler 5 treats area b b veal; bing = a-inng t bring I deca 4 2 ———— wim aaa t um att Veet jit a function” 4 oa void opuccios ++ (ABC! x Pras Pa th y [eee Pike sig i fun fuiend yold vpeuator <= (Rational! Ration! | Yo (anu & b-num e=b.num # a. dnum) Ludlum a | the Aveta a; \y Scanned with CamScanner ee muse tt . aye +425 ase 2) dy F053 tase 3! dy? to.5 $4, wae diy doy dg f dist ¢lass obj. (ue! + fs worttig if, WE ovenload ‘+7 opt fo cat. class» ued! is not working a we = oyeuload +? opt to add 2 distance Claas objet pecause hee passing anegat ts a fort value: t work Wwe a tooveuston convent the | WH we wand 4 eq. to cueate tonepemeto®s which jloat value in diet, object. dist (Float 2 v fea =f) inch= CF -FE » ‘ ub) eID) class dite OF int fects float “inchs Public: dit O x feet =05 Ynch= 0.0} +o los dist (float F) a ww feet =F; /6 Ench = (F- feet) x12; y void Set Oo cout <<" eniee feet cin syfeet pinch; Snch"; y yord show) xX tout ee feet inchs y dist operate (aint a) Nui t> 4feut F feet parfeet ys tench = Tnch + d-inch 5 while (t-fnch S=12) 4 4Pach = teinch 127 qefed tt) Fagor 1) Ne ») Scanned with CamScanner Void main () x dist disc), dr sey, gp 3h dg =di tar; da=dettos; dg. Show (3 J Case 3: dg lo8 td ja 00) i, we evarload 4 woukl ep fi Class and alo _, Cena huey r+ Beoruse tt Ue necadard which clax ae ovtload he a ye dist have @ Cooveston, ot dyetoad _dlucam op Heater ble know That in} we wed | Dr ke type it W6UK™ int wot Hh 5 din) a5 tout a; bu iy (vo) ut 9 SSX tout 22 X So we sags to ad. cit but Hemembue when we syudload otuuam s9pecote”, then the casting object b cin [ cout \ used wlth 0b) we hot wouk. bur we Know we overload the same as those alas go we convent Os passed ‘ ° usu hue class Complex Ink steal; int tng, publie: wid opocarr Q(iepea 3! . cout<«< "e 4 a tek steak eg) tm S> Co steat; - Cauteg eb), MUS dane as ‘hose clays oF none Solution? =—— in wlth on type phe CALA become passer we Kno that “in ad faced ov lo aaltng. Couex become power. fuierd dist opeactor + (ditt a, otiit bd q dig th t fet= a. fee + b feet) {inch = a-eIncht b-inch; . while (tach dS =12) ‘ 4 e|nch 12) fiend {einch = t Ine! ; Efe ty Keun U b Scanned with CamScanner in > img 5 patter ceCostieam Sout, Compler Ba Kol : put “Ce cceals puree img 5 \ h void main) Cramples Cy tin Crs Count G5 ) ats Rational x, inr num) tnt dnum, Public Lin 5 Rational ék) furend votd — operas yy Cistream « . cout 22 "enter num dnum j Jn» enum, to »> vdnum; ¥ ( sssream out, Rational £8) jend wold — opucatos & Out 26; . Cur b= owe, (1) a7 = 84°6NT, 7 Phasf aH 84°07 { yA ful) be GY opd AY pe ( re Scanned with CamScanner dha Wynne et : ype PP clay A407 en phy Fk boic TH! (Gaeta Conwihi Feng awe e Clow Ar | dit ee ou 4 Pest) plo=t iy, futlic die a * peat cae) | & Pau = 0°97 + f~ i & )— a ON res = 2 PF; ° in €- fet) a ii) ; ~ ued see U) L 5 a usd snow a 5 2 7 usd we U Y dig dy, die los; L dy thaw); 10/6" d) (to ‘s) Scanned with CamScanner Gonuenion opto” | o ‘op pafoar dotype ©) ‘ at Stee = _y Gane awh & o g ret, ie cpaltor pPtect ©) 4 Preaft 4 p e lear por ay } vad ewU 4 Arete 4y Ay PU; CO ay: shavl), (0 6 poet POH; lost CophioG com j vy Ve ° | Scanned with CamScanner yxy frow Creek 4 Gevete for fwore Saw Mao fiw for pathastan fy pe fay, a troy parksobar coor oly {ucoe fen call Vv Tw ath Rewoty Cane De Bam 1h Cal? Gewt fn WSS deploe | | void show an soe ») 8 out ca" "eb; , veld main (0 “new (56 )5 show (518.4); | show (5, ' PD; I : toe qenente ofan we ean aly eueectté ial at: qhe peng & we can ran fhe et " mow bul geemember auhith ‘er any of pe hole ype in <> dYore ebjee wul Pa + getanation. at ta time fF PY | z md Scanned with CamScanner Sane Tr? template ¢ dan Class ABC < iT a; tublics void howl T 77 ¢ asf; bray | cout « accb; x » fb Void main () 4 ABC dr} gy» show (54's nec < Afloat, chareas, en "ye eve dy. show (5:67 'P%7 fa rs cin File handling ] = Sot ushich it tg a te chntque puovide the ieee + uit, the hep a we oO" er dour tre dato in. petra | gouage, and when want Wh | a ‘back » Foe this We | Hg. famed location | file Sse ¢ Fsteam hd’ "i it vy due. Scanned with CamScanner dius gon wo put Ee ip awed go wnt chau by chow in pee (i) party used wo ead by chan tn bee [fes pea ol cout (ii) eof) use 0 cheek pie is cn ‘ end ox net ay tsoearis | 0 Read five dota pe" be damzuiiy) (os ¥eam- with z Se ah 10s ¥eam—- with ass ~ din: oan object = wT ent na eS 4 and puted can ud opuccctore >? which 6 ised ed tn base i main () Clase isoeeam: Ve 3 . ifstueam = cran’}; cut: Is an 6 ; object os bream cha ch; ~ sc class “do it ¢ “id puck D anes ite tls eof) rl in is base the tn. gt U5 Is Gbpailond cour open Sn mode. binary Scanned with CamScanner ganda ew fun y we want to tlw data andorly file we have jun wi seek U is used to set get dic an cesimech Wation ‘in file> ‘ ay (a) single Ox eument * seekg Epos byte) Se On pawst cular position tn file: seekg le) get on bth by Fe eon beg. suekgl@) see on oth bee from bea. (b) double ument 2 seek pe specter tive Tosi: 4 a foss; wt joss: end see (-6 ios: / ar) se ge pointer. 5, bute back quem ct postion pil sukg (+4, fos: : beg) gut 3 byt chen yom “ beginniog Sekg (0, fos: end) seb, oh oom end means on ene: ‘aaa oe oth hoyle byte (i) tw ysed fo seam * 4 ae ponder the and slg 0 only up pornHe posit seal) seupe vite 8 Oe B to seetg0 wouk On in Case 4 qet points Chass quent | q 4 chan name C t ine Rolney int ages Public : yoid set () to] void eueate OF void show O35 “vw %. . Void main () ey int Wy chau ch) o tout cen enter t 4O% dud doen cout i ent 2 for views dyuclt aconoel Cot ce" gn 4 5 ST wuase stall Scanned with CamScanner : (rerrcrccrcraarae manana aan ee cin dyn; if Weat=-U Guate 0} ele Ip -a) show (} else ’ exit lo); tour cevdo u want te continues tind th, Yushite Ceni='99} y Void curate () x etudent Si} - Biram Fs feopen ("ARYL ios sapp)) S.C; “Fouuile (Cobar +) AS , sivee csp} \ Fuose 0} y void oisp() x Student S15 int 05 ‘ jpswream = in ("an"); in vseetg. (05108: end); int pein: uel), at pe hum = P/ si renfi (5.93, ! ye agect aout @ "mut haw. & num'e¢ "Recs cevuith ged 10s Pet cout of ste i } ann Se Poy andl Exception_hat 2. ; ‘ Li echne gue wht a we ne the yunding wed 40 nan CLO exception eet aonditibu uxtth the to the nesmat yew a BF 3) Ws stopped * yes and 70 vi awed oycepaion anal like div/o. void main athose abnorma ues on handle int me ¥ cout cettenies @N2:2 cin 305 ny a= s/n; is cour : To handle +hese 4ype 4 dituation c++ provide G new keyword. , Gita Ciipeasch Gi) Peo Tey is & bloae %. which we tusate. quite those’ pau if paoguarm in which thane” Y eetepeien 48 avatlable,,\ Nosy Scanned with CamScanner P ig a handler block in at . we walt those par Ly eg ene want 4 execu when OOP | qencueate * go Wuow is wed to fue ap 197 [ shioug Hype ’ showin O49 void main) Xint 0.05 tout , igene= mew 55 else’, (nz22) : j grow Soo> ny else Ahyvow yeach dur) furcd | hand! te Sint") y Caich (double? tou «wy handle float! y. Catch tehar) eg nendle shan Y Fn Scanned with CamScanner f Gach au handler owe want a handle cohi'ch Can handle any type Cacepton shen we used Catch AU tbls mie conte Cory) tr Catch . aie uty 4 Xs Ze OW tne 0 thuow 63 else th enero) thuow S+6), else _ thew!) Y catch at ('..) I. “9 can handle aul 4 Cout cK 7 t te x bur to we it owe have . Aome sual + ee di) tL we used atch» all swe ° not used 2 . oFhehs wo 4 used use bY OMe Pau because ev ae corduol ° 4 thansjer ous Se Bo comple time lows Jus p y. F eaten (Ws) Lunt X uv, 4 € eat UG catch sb) a oe ' | 7 F tatth (ed pen Seuteh Ut = nated bey ua if in wand we) COP, wHite one bry within another. by cated need when emp qeneeay gn this in cue ty OMY GPO fo ourex catch but Yt enutate in inne vy th cu do ‘ina Catd 7 it ‘mate then puocds + otheuwtse order catch ~ 4. ip (nee) torow 55 gunz) ow juz “Mt ytnsd shiow 5. 4+ Inst ee 2 thuow 85 > catth (double) Cout MIM; i Catth (hut) as dent oud Scanned with CamScanner want WE CON hana le exceptions in ponent Ne emuipace an in child ‘a int n) we can ae {em le acne, void fun 46 f (n==1) thuow 55 else thao |p; fun ction Cloas which Cap be used latex. Sy tar name votd main ¢ Oo int on, namespace cout <<*ént « n; ; Vou able 4 function f F Class fun(n)5 is ys catch ( tnt) x , How fo use names pace menbo cout ce 9né n0."3" iy we eae a vi membur define Sn we have Quays: sed he namespace » catch (chan) x cout <<" characte’; \ Jrothh she help wiih he help ow flamupace aame using Reyword pete usig names noms namespace i, Oe, namespace:: fun namespaces clas Scanned with CamScanner C nants pate "BC 3 { XY . | % nt a? lo; | x Sint b> 20; y oT £ ~ , f Noid main) using namespele | ABCs, hoo yor main OD Se int ars; ) ‘ + int yg: \ int €°S5 se Tur oc "my , cout “KQ} ‘>> Aig cour <

You might also like