Address
:
[go:
up one dir
,
main page
]
Include Form
Remove Scripts
Session Cookies
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
38 views
30 pages
CPP Notes - 03
Uploaded by
Nikhil Dongre
AI-enhanced title
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
Download
Save
Save CPP NOTES - 03 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
38 views
30 pages
CPP Notes - 03
Uploaded by
Nikhil Dongre
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save CPP NOTES - 03 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 30
Search
Fullscreen
| Pol morephis aa) a A Tub $4 a Reine: | Compile Time iS |___psly morphisha Po mmovphi yw [ A eae aw 1 Eunction | | Operator Vir ual j + ourvlnading Queelosdling Function q Note. Compile ime poly mor phishn Zz m called as carl binding aol yrarphisss 2 Run time palymerphien is qlSq called 7 late binding polyimar phishPointers to Devived Clases in Cit: \\ 1) cla RaseClass_f public 2 int var. base * id display ¢) £ cout «" Displaying, Base class variable var _ hase ”
di play C)| Vivtuel Functions in G++ lass RaseClass { public i iia Orel cus Ca le ite ol ispl £ coul «"1: Displaying Base class variakle var_bese” << var base <4 “end * ‘ Tut 56 i cla CerivedCla public RaseClass at public cs ink var. derived = 2° void display Oo { cout «2 Displaying Base class variable var- base” $< var ~ base erend|' Pa. SED ie plenrincma ber V lass yoriable var devel
| they | ane aceemteoeaby objec a = kero friend | \ a Vietual functions cam another las A virtual Puncbion ih the pape clus might net be used. : The ow viktuoll Pubebions iis det ined A base class there iS ps necessity ch eedefining iin the derived clas - Fut) advantage of virtdall funchion is jake, ~ by eae pcihlers | Th We commen mCueienennee! The clisplay 4unctioh Tom clasy VShittovic ee — cla Tneome then buse class = display ©) pun = Ex: Ti Gel@aar Guise class) Income. in tuk S75 then A Tes ited sian a A Rating Me el 5 sfars qj The length of movie | dy AS hou q Helle | ie_Virjual a | i Ab pstract Base. Class and Pu fetta tora game (rns ete ems iy Abstract base class is a class hak has ak lea one pure virtual Surction in it | ly The classes ae are apherriting Fhe (Maceo. Ge lees la: must Lvietual function of oF abstract clas Lothemuise compiler will throte an error 1) Pure virtual function isa Function that aperatioh and the he valu doesh't perform any function jis declared COs, ighing © to of ure virtual’ function Gre declared in abstract classe anmey abe Gallo b. Sat ) just changing che ihe eure virtual Fy* a ok cede fo understand Function TutS3 a The. line of cod@ aS ba tohick chang eck to Miciuel void! display C= 0 After declaring thiS we doesh't hove access Pt domenica display()_ function e mw | _ declared disday C) Pune MOM olathe sclewived classes ial s + class vsMMovie and * class ‘ncome Pure virtual function is also do-nething Function , cajled ES “|(¢ Beng if tream 2: of stream ==> derived at
| # include
~? -e ° 4 aa = i j qe tables oa ee x | For opening tiles usihg Pongieucts~ and 1.) fs becom! ae Teall Weds Estreambese Me bream base there are _ Using the. member Punction open ( ge th duae tae pening Files” using consbructor and rea \ Be int math 0) tf Jrwing $2 og e itshream in ("Vikalpe Ext" ) 4 Il Reading operation | Hie WWeryoe 25) lee acthis loot\l: ip xint Sooty one | actiine (in, 52); word and step otter ‘space’ coub << s2 ¢ Ste. prin} whole line ve }urh 01 t Output! The senlene written io “Vikalp-txt” file iS _pwinted out Note: Ww an Read/Write file jn the sami | preqeum emia) ativan Gal Zee For operih file using open O) ae eot ©) functions g fine @ tp o : Wwe hae feo function to open file open () andl tot ¢) > End of tileotslreasy --> writing operatien : ¥ } ingteCam ~-7 veading operation (* i ee es inten gray ‘el Na pa a ~ a} | declaring an abject of the type sts} ree a dg : | obstream owt | — = | out! pet @ ample 6O-txt ) \a JIL. tolen huge any VawiabiMWateadis ot ouh _ we opel any File which has: PEF WI SSich 1, Spey e out <<" This) is! we Vn | ouk ¢ OM Thin ise eles Wel 2: out -close ©) | losing the Nihon) fais goad peatic rcturn 3 Ex2/ | int main OT = 1 [declawing an abtet cE the Ree ich —~ iistream il i. [declaring Steitsgs variable sm jing sya Si 3 ies a(Pace | et 2 mm opening, One Me, wee igs yee ih -npen C” comple go txt)” i Giving output the steing lines § Pee enn “syq'F until the Tile Sreaches “the end ot it hile Cin: eok () = = 0) SMT Usigay Setline slosh Wevwhale Vhe getline ( iy Agim )y ih Sm cout << 5 Le end] | 1 rt fur Of Output! This is we this is also meeet. met oN ast i. intaiked y 2 Templates is used te eae BR . TE sivtipal CDasii epee yaesse) ay . On 1a: | ne data tye syntax for Templates é Template
myVec Coty) 5 = vector
mytvec Ceti); j Fx: | #indude
using namespace std; template éolass T class vector public + NCE Whos int size ector C int wm) { Tut 64-1 Sica Ln | avr =hew 1 Csizel ° | 4 T dotPreduct Cvector &v) £ ie clEone pee Ceiba | dey = tis See Oi ev ore Lil, j ¥eEGrh diyri a ee Ot UCL}. | a é vector «float? vite, e J vechor 4 with a float gaye ——__* Vi-arefoe l= 14 Vd: ave fils 3: vi-avrfoj oly “+ veClor
v2 C3); | tow 2 wilt au Bela cherie typ V2+ ark fo] 291; V2: caste! GS Meer \2, yee) ec ; ~ | Pyat = Vi-de Product (Wy: , cout <4 ¢ endl | re tourna; 4 4 6:32 Outpuk ey4 * C++ “Templakes with Mulligle Poramelens * # include
uu i Nam espace pda: Spaleice template < cle Ty__cluss T2 7 class name OFC lass £ bod a thE waind) £ N body of main i Ext class | wy Class g public F int data 1 Tubes char lala 2 void di play O i Bee ie lataieen tier pes daram q = as Lemplate 4 cluss Ty class T2 > a class yay Clu 4 | public § | Ti daled ae | eae cleaneda myClige CiW lah ea ie a ii ~ datal=4 i “Ne a dafaz=b° “a t a veid disslay Of im 6S Couf cc this yer IN Ze this» Jair a ik a 4 —¥ - 1 tnt main ©) 2 my Class
class Vikalo { puligne [Bk ae Tut 66 (li vio Ws alt a NICO Gie mea tio ye iratire Jee a= x 1 Ee 4 e=2 void displayc) £ cout 44" The syalucl of yo i .s4.9 6<.end] | cout" The value of § is # <¢b << endl: ome «| The Wale as opie 55 <4 & << endl ast toPe int ity 4 thers “> NVikalp 2 & joel anh = wa wd Se at Avi eal pi 2S LA os Yes die eee it cout << eh 1! \ 7 Vikalp < Heat hare char Wo C46 ( rai ome display) return 0+ a ut The value oun S M Wie : i Uy M Ci SR ian) | The value f Cue ead a y i sl - | || Ceti Ht af 7 Hf | ti i i 7(* no] 4 ic J _*Funchion Templotes and Functisn Templates wi Parameters L # include Ziogtream » casings namespace sid | template < clogs iy dlaggaiess 7 loaf funcAversae Gime ab al Wet Ploaf avg = Catby/r2 eo o returh ou : Tuk i 7 61-1 ht main) t I lee ancl. a = JuncAverageC at” peintt (" The Average of these number is ‘/et a)” ve Hen ot i — The avtwage of these yumber + js 3:5600 oR template « class T 2 wrod swapp( T 4 a Tid bd# inclucle ~iostream 7 using neim es pac 5b template 4 class T class Howse 4 public « Tt datay Horse (CT 4) i at Tut dala -= a ee! void display O) 4 ie bemplote 4 class > 3 yoid Horse 417 2% display) 4 cou se denies 1 int wacin GUMS Horse 4 Moat? WCS:7) |ft include zioslream » . buns WON ESPAce id void func Cinf ay & Reva daw jal alu had Wl INGE Gym arc chd | \ p | template aecllcs shail 2 void func Cray C coute<” Tam demplatised func c) 1 4¢acéend |) t Lint main © func (4); J) Exact tach takes the highest priseit ve}urh 0 | g ] } Output ASU iled yy nding eae GD: 4Ani isi sia Daa int Y fe nd \J ond classe - We) ewe these \_ 1 (3 her unc} ener This helps. us : i, ed classes and functions * ompone A tS eee n Sule ieee Wwe have three comeonentS ih STL 1: Container. 1:| Alaovithm Secs " I] 1-| Conjamens | Conbaihers $5 an object ul Stewes dala we have ditferen} confi haviha theik own benefits = 0 i Algorithms: Algopiths ake oqo set of ~ ins teu fen which Wnonipuletes the input — data to arrive alt semel Nedved pecul| —-— | Th stl, we have alkeady written "q & alaveithin Smexamalee 1 sot sow — data, oh scobelil smelislements in acs Thi algovithing use temolate | Wanerichs. A =| 211 ceaisvst eee sl ects hich “echcr Je an element jn a container hand Mier W ime teeTheir basic ab Teel cat neenll qlaaathe to az : oO the ontaine and plays a very vital rele in manipulatich of the dala Ex | Container ae ES tia si] t | poinler, which are tree fo move dleng the | conteiner H = | Containers are themselves of three types cee eauence Containers 2: Associative Con{ainers Derived Contaihers | 1 Seas ence Containers ? slores the dafa ih the linear Jashion e&—O— © OOH Elements are addled here oie in the beginning Elements stored in linear Jashion nee__contaihers include Veclor List Yequeue ele these awe mast used 39 | Assaciative Comfainers i stoves theik data ih 4 ! Anes like structuee | | ® uh ear 3 4 © ©_ WScins Be the. ~ So atige eo ~ on jain ev. nee “roa ete Se i Mulfisel Vlap- multi Derived Containers 2 odelliv They deal with real ite nacclelline Some cxarroles oh Aewived! containers ave ~ Shack _duewe Priority quene _ehe —— [sm ilementiawetadded as a 16 well as) wemaved from h Stack— |2 aa 38 | They deal wilh real it | T Slack Pellews JTFO Clash ih Sis} out) privcip: aig Lleuit me QO: 9 use! alle FTF oC Fikstih Divst Suk ) principal Nele: Thi bopics stack heap eas ce ope — studied ieee tele jh dois — structure onde algorithms a#| When) To sen cohichs: Confainers 2 \ In_sequence containers, we have Vectors, | which hac alle wing, Sercerea \ pest \ DY Fast RA CRandom Access ito elements ih i 1 CoMpParison jo Qeray \ 27| Slower insertion and deletion ati some random - position, xcept at the end j a) Easter insertion at Th end | Bin Wisis we have 17 Random accessing elemenis is Joo slow because ev. by clements is traversed ore psi ter. 207) Tiksertion andi deletion ah an position velalively faster becouse they hl, use pointers | which can ec thy ke main pulated * Th associative canlaihers every operation ex cept wandem access iS) Fasler ih Com parissh to any other con}ainers , be up| Wncew ling low edelelindnianorclemen’ ih associative. we cannot pecifically tell which opewcitjoh 1s Taster or slower we'll have to inspect ever data Olea cluye seperately whieh. 1S given ih | Wolee detail in DSA |Need to study on Mlemben intializers and Composition ,imere in details ~ Selelecien| ee ein ializerion list climinafes the need _ to place explicit a ig ments inthe Constructor! body. Also othe snitiolizedion | clecs hot ene with cere a yThe member initialization list waa used fore reqvak = Oy Pegular voriubles and muct be used for cons}War = b* ne constant variable, private 4% ink wegvar in ons i var — > | Right way fol do this ==" PIE Vel jn) coecamipecshichummeinlewil amallegia hel constant it make, good sense fo use th member initializes synb an A ni mber variable must, the constructor initializer list Fxiz) Class Person £ public. Persen Cstving ny, Birthday bY | class Myclass £ Muyclass Cinta int} ) & reqvar( a) constvar¢ h) » i 4 | __Private ¢ con, in mst var) nome Cn) b tc { i private % Siving name ~ Binthdey be as, aw FFinclude * Birthd gay = This’ Toate header and wee tiles /where youl cheat ~ Ta file’ like thS and call it ih ansther function GSP nclucheer thew.inf sen Ag Gg int mother Age = 23° \ iE C son Age > mother Age) 1 int son , . ; | | row 99 * iy iE Conf yiwethee ge) L reghain Pah 3 7 senAge Gmather Age --7 fi - row * Wren alice. - ; = | catch Cint x) { i] ei 1 1 oi out << “ ee age alues - Epron ? 22% - Presa: ill un but give, a exception err : 1 wh _songAge 19 greater which EPROM ccc aiteaHl 2 kong age wolues = Foner a | logic "that sonAge is hever gb ater than i mother we Say like that | ele: Th the throw <¥abewment the ope cletewines @ Vype Sew the —This can be ony eyphession & expressions wesulh will The exceptish Throw, oy ieatehplanay SME ond | | mos eat T
You might also like
OOPS Handwritten Notes
PDF
No ratings yet
OOPS Handwritten Notes
20 pages
Java Handwritten
PDF
No ratings yet
Java Handwritten
18 pages
OOPs Notes in C++ by Arpit Singh
PDF
100% (1)
OOPs Notes in C++ by Arpit Singh
20 pages
Oops in C++ INTERVIEW SERIES - 2
PDF
No ratings yet
Oops in C++ INTERVIEW SERIES - 2
24 pages
Oops
PDF
No ratings yet
Oops
21 pages
C# Topic 2nd 3rd
PDF
No ratings yet
C# Topic 2nd 3rd
36 pages
C++ Notes FULL - Compressed
PDF
No ratings yet
C++ Notes FULL - Compressed
176 pages
OOP Prelim Paper Solution
PDF
No ratings yet
OOP Prelim Paper Solution
27 pages
CPP Notes - 02
PDF
No ratings yet
CPP Notes - 02
30 pages
Core Java
PDF
No ratings yet
Core Java
51 pages
Endsem Paper 3
PDF
No ratings yet
Endsem Paper 3
45 pages
OOP Practical
PDF
No ratings yet
OOP Practical
30 pages
Lec12 (Topic 7 Advanced Topic)
PDF
No ratings yet
Lec12 (Topic 7 Advanced Topic)
47 pages
UNIT:1 Þashath: A Pupiam
PDF
No ratings yet
UNIT:1 Þashath: A Pupiam
49 pages
Bca 3
PDF
No ratings yet
Bca 3
35 pages
Unit 3 - Relationships
PDF
No ratings yet
Unit 3 - Relationships
23 pages
C - Home Assignment
PDF
No ratings yet
C - Home Assignment
8 pages
Abstract Base Class & Pure Virtual Functions in C++ - C++ Tutorials For Beginners #58 - CodeWithHarry
PDF
No ratings yet
Abstract Base Class & Pure Virtual Functions in C++ - C++ Tutorials For Beginners #58 - CodeWithHarry
3 pages
Computer Programing Lab PDF
PDF
No ratings yet
Computer Programing Lab PDF
105 pages
Adobe Scan 19 Oct 2024
PDF
No ratings yet
Adobe Scan 19 Oct 2024
20 pages
Oops 02
PDF
No ratings yet
Oops 02
25 pages
6.096 Introduction To C++: Mit Opencourseware
PDF
No ratings yet
6.096 Introduction To C++: Mit Opencourseware
19 pages
Opp's Assignment2
PDF
No ratings yet
Opp's Assignment2
12 pages
Oop
PDF
No ratings yet
Oop
20 pages
NCC Unit-1
PDF
No ratings yet
NCC Unit-1
25 pages
Polymorph Is M
PDF
No ratings yet
Polymorph Is M
27 pages
Oops 03
PDF
No ratings yet
Oops 03
14 pages
OOP Endsem Notes by DK ?
PDF
No ratings yet
OOP Endsem Notes by DK ?
27 pages
Java Assignment 1
PDF
No ratings yet
Java Assignment 1
22 pages
C++ PYQ Programs
PDF
No ratings yet
C++ PYQ Programs
16 pages
Oops Assignment
PDF
No ratings yet
Oops Assignment
11 pages
Practical File C - Program
PDF
No ratings yet
Practical File C - Program
15 pages
Pranav CPP All Programs
PDF
No ratings yet
Pranav CPP All Programs
14 pages
Oops Assignment 2
PDF
No ratings yet
Oops Assignment 2
11 pages
18MCC23C U5
PDF
No ratings yet
18MCC23C U5
7 pages
Oops - Assignment4 (Piyush Nayak)
PDF
No ratings yet
Oops - Assignment4 (Piyush Nayak)
12 pages
CS201 Handwritten Short Notes (VUAnswer - Com) Handwritten
PDF
No ratings yet
CS201 Handwritten Short Notes (VUAnswer - Com) Handwritten
13 pages
Unit 1
PDF
No ratings yet
Unit 1
18 pages
Dashrath Nandan Java (Unit1) Notes - Alasso
PDF
No ratings yet
Dashrath Nandan Java (Unit1) Notes - Alasso
11 pages
Thabrezali 23bis057 C++
PDF
No ratings yet
Thabrezali 23bis057 C++
10 pages
OOPs With C
PDF
No ratings yet
OOPs With C
8 pages
Virtual Function
PDF
100% (1)
Virtual Function
23 pages
DocScanner 30 Sept 2024 2 33 PM
PDF
No ratings yet
DocScanner 30 Sept 2024 2 33 PM
12 pages
Multipleinheritance ObjectClass
PDF
No ratings yet
Multipleinheritance ObjectClass
14 pages
Imgtopdf 2909221401056
PDF
No ratings yet
Imgtopdf 2909221401056
39 pages
Oop Assign 3
PDF
No ratings yet
Oop Assign 3
5 pages
Rupkatha Bhattacharya, Roll No - 03, CB303, Assignment
PDF
No ratings yet
Rupkatha Bhattacharya, Roll No - 03, CB303, Assignment
4 pages
CPP Notes - 01
PDF
No ratings yet
CPP Notes - 01
30 pages
Unit 6 Virtual Function, Polymorphism, and Other C++ Features
PDF
No ratings yet
Unit 6 Virtual Function, Polymorphism, and Other C++ Features
8 pages
C++ Hand Written Notes
PDF
No ratings yet
C++ Hand Written Notes
15 pages
Inheritance Chapter
PDF
No ratings yet
Inheritance Chapter
35 pages
8th August Classwork
PDF
No ratings yet
8th August Classwork
3 pages
Unit 1 (B)
PDF
No ratings yet
Unit 1 (B)
25 pages
Oops Using C++ Unit 1-4
PDF
No ratings yet
Oops Using C++ Unit 1-4
187 pages
Oops Notes Curated by Sameer Raza
PDF
No ratings yet
Oops Notes Curated by Sameer Raza
21 pages
Chapter No-02. Functions and Constructors.
PDF
No ratings yet
Chapter No-02. Functions and Constructors.
27 pages
Adobe Scan 21-Dec-2024
PDF
No ratings yet
Adobe Scan 21-Dec-2024
29 pages
Complex: o o o o
PDF
No ratings yet
Complex: o o o o
9 pages
OOPS Notes ? - Removed
PDF
No ratings yet
OOPS Notes ? - Removed
20 pages