Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
47 views30 pages

CPP Notes - 02

Uploaded by

Nikhil Dongre
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)
47 views30 pages

CPP Notes - 02

Uploaded by

Nikhil Dongre
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/ 30
Ext | Cliise NUeieee inde ci OULNIGmNe Number C - q u “* ee Number Cint hom) £ a= hury + 7 Number (Number Adi yt Cout <<“ Copy construchoe 15). call Bb.” cee Tut 34/ ; Tut 34:1 Void dis ple Gy x ", The sentence AG is het print tf “onsthuetep tan! nei. @) se ‘call Number Geis) al 250, 8 display Oe My - display @) 2 dis playne Number ziC2) ) 4 Copy ghgthuehow! invoked 1: oi plo. Gyn IL Copy constructor is hot call Numbete 23 = Z ¢ IL Copy constructor ihveked 23° display eDik za Werlalize actly reset bl ok XO rejurh 0° 4 Oubput” The numbevw en objech iSO The purmber for this object is 0 The humber for this object is 46 rez! Copy constructor called 111 ted The number for this object Nea S The humber for This obec 15 45 Copy constructor call Wl BIG. hum Gert vee “ic Shecw is 7S . - 7 a ice anf y + eh aa an ereaeiacn | j )_Ostruclow never Lakes dees it returh o \ 2) | For mokine, dectroenor Cw) S| Refere to. Tutss for Godel. jike thi eae = 7 Note! Wwe car also writ cout rm F# include TE can replace by something else . Bi intents Synta Ball visibility, Mede. Dewived class syntax class Ef dewived-dass-hame}} me Oily -modet} base -class—hatn 4 BR cm tcte MMi uLme tol ln. ig dehault isibilib mode is private (> There ae two ype, + visibility meee public and privabe Private, visibilih, Mode 2 Public! membens of th hase cle. becsm privale members ot th erived class . 4 | Public. visibility Mode < Public members of the. ase class becomes Public: members ot the derived class . Prwale members are never sherited of bese class | Public members should be thhewited with _{wo_wmedes which is private 8 public visi bili ty mode . oo Ex col clas) “Emplayee | " ee public int id ie Float alaxy * ee Cint inpId ) ae id = inpld is Sdlaxry = 3405 ie 4 i 7 ec () th . _ ma Jey Pe aaieaininne v8 i public. Employce i { public § wht langus Codets Pe egrars Cink Ep ihpTd) id= ih pid languag clade = ike int maih CS x { | Em ployee harry CL) pohan C2) cout < harry -salany, He os a he public | ae ok void ay (> 7 ca coub i a int main C) 4 . utput t How ave you 2 7 | [kaise ho ( Tt we Comment out denived function if prints two times Hots arse yal Because it call the class *Q’ Junction , tee oe Fs | Virical Basel Class 2 — = Syn te. for virtual Race Class ; tt include ios} ream? ; u Og) jrarn € Space 5 ap la Aad clas. ‘x plablic aka ; void say) cout <4 “ Hello Moto ” endl} a i class @ : public virtual A fas irtual public A leer public virtual AL f° class D : public B public © the JE [class A | J ae al [class € || Q ond Gand Bis & c's_A ~Tut45} D es woul 2slGA) = aa ean db R cud Gis lA This leads +o — Virtual Base class wesolves this ambiguity . ———— ae ieloss|: | * | Congtruc ns in Deeivecl 005s — SO victorin derived oy ih @ittats TE base class constructor docs aT ony gisgUimern nis ‘there 1S ho _heed constructor in clerived class. But if tal gre oheévar Wore a r9 a the. clo consthuctor devil class ma to pas arguments to the Reseamralet constructor It beth Lase “and denied classes have cons bructews, base class constructor; exectted Biwet Constructoies ih Multip| Unke wirance, Th multiple | inheribam ce oe Weclev Gy twhich appear ih The class | declaration th we inhewitance The | congbeuctos ff et se I ote ¢ But if virefual ni came ihjo 2 Spedal Syniox Jon Consductons y C#t supports an pecial stax for passing ciegumen fo ynultiple base classe g aS the constructor of the all rived class receives all the argument at once and then will pass the “Veullg fo the respective base classe: » [the Hedy is called afler all the constructor Ave, inished xecutihg Derived = Cons bructon, Cag org2 arg3, 0.) 4 Buse 1 - Constructor (arg i, ara 2) Base 2- Con practor Cand’ 3 ange) ¥ Basel = Con. teuctor Cotogt ove 2) * Special Cage of Virtual Rase Class » the cohstruclors for vireiual base classes are invoked before an nenvirtual base clas 25 Th thewe are multiole virtual base classes they are invoked in the order declared —2»_Any non-Virtual base class ore theh wa ond thucsl erived 1S executed . Ol ex: | ce Sat i — = i a public 7 “i i Base 1/Ginei wel J da ‘ai =e a a ct oid print Oaja@acel (void) 4 7 Tutt Pe PA er RT ot ‘ . nl clac. Base 2 £ a at int data 2! ——- public: — | Base 2 £ — om yet _—s i datad si = 7 cout Derived Cinta, int bint c int d)t Base 20b) | Rase 1Ca) ra cevived{ = ¢ | cevived 2=d cout <<" Derived class consteuctor called” cehdl * j a weil print DabaDerived Cyoid) t Guuitinel Value oi dewiued 1 19142 derive dil The ale RNa aes | iodo The value of any [i] is 20 The value of arr [2] is (20 Ab et oe he elas clue ty ane oe Ge =) Gloniee—en lO) aie fel a Se2o ls Diets =e Grom celete [Jarre | cout <¢ The yalue of avr Fol is” dare lo Jez end |’ uy 56 1) avr fi] is" < pt -> ostte e = ini * a) = 47 3 it * pi ai) ha. 2 pte= 999: ih int * pte =999 > ewror, Aeub€ Je clan ati ee ie NAMES "2C* Cptr) < | out ce" the imaginary part isa” Beira iva i tuts! 7 me... | i : 4 ant main OC) fy 7 a i ff Eom plex awn fd ii I Com ale x * phys See xt i | Complex * ple us j ia Z a: (ond ¢ , ws C*eiv) cet Daly Ca Fiat —ia = I. p tv =" Seb Data (5 (iat SB, ‘ He sb | Fl aaa Le — — SES ST aT TR Complex * pirl= new Complex £4) ° ie b> sic Dog Ga 4a, aie lier get Pal g GW. Pp D T returh 0 | i Fx: | class Shop £ cy int id Float price public “a I at b 2 void getDataCint a, flo ee on < c id=a ne =f aie E TutS2 ae qetData C) Bo a The id of item is” > pera + pir -s set Data Cp ay) bye ++ i 3 Nol (eka Gemma ns Ecnuledea Meu ee ei Nol Uc vars enubeetr thi vor A 4@ a-setDatat4)! A a-gctDabaQ PA yeturn 0} de Note that only member Factions have a This peinter "oulpul Tiigehyalugiest hg) wana EX im i Ao ‘nance public — & set PataCint a | a Eihnuey SOk=a Glee returh * this - Sf yeild getdate © Cpe ie Soluce chum Wg 1! d

You might also like