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)
23 views
14 pages
Oops 03
oops notes 3
Uploaded by
anmolbansal1969
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 oops-03 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
23 views
14 pages
Oops 03
oops notes 3
Uploaded by
anmolbansal1969
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 oops-03 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save oops-03 For Later
You are on page 1
/ 14
Search
Fullscreen
95 /\ /2023 Th Fundion oveuriding., derived class pxovices specific implumentadion Fox a function thar s Sa ol@eady, dikined in _panunt class » Twis allows wna derived’ ass te override the behaviour of ru function inhaitd fw parunt clo» - ode= | Rindudecbits|stdesh> | wing, mMormespace Std: class amimal § . public + void Speakt)¢ cout ¢ “ speaking" « endl; oF Clans dog 1 public animal t - of publi ‘ void speak) § coutc" barking "Zeemdl: y. int maint) ¢ onima) a; os speak: 5 dom dy detpukU; af zam} 4 é Tb parent class “Ra pointer child r abject par ouote hrte hai. eur child (); nila clom Ra pointer _parmt DLLLULLEbeeueddddad b peck par crate hate hai. BOEELEEE h Luit, pornter- type pr depend rego. Rit i function Ro accon karna, By ¢ data mumber tho. memba, | has Bur, fF wre womt Phat obyect-type pr depend kre, then male te parunt clay Nivtued. SSMUSBBEBEB EDS!(Note AQa isi code mai parent class ko vistual bra denge them obyect- type pr depend Rrego Aother Mhom pointer Hy pe . In that case, pales ourpur= speaking, barking , barking Speakeirey Heinctucle chits |stde t+-h A wing. Nownes pace Std ; } _ clams animol ¢ __public: void speak e c __ Gout co's peateing eéendty yO zy, ; Cary deg : public _amimel f Publics void speak ( ) couk << “barking "<< endl; 3, int maint) £ Omimal * ad: = Wau animal (); _ ad ~> speakl); dog * di = nou dog W); Ad speak), omimal ¥ a2 = neu dog t),; a2 > speak); dog Faz = @og*) nun animal ( ): speaking 42> speak) barking. speakin teahingdeclared in the base idelem bu “the dlenived clas - Kohen ore m objec of dexived clas — JMsiAg co _ | pointer_of- base class, then. ved class “inmplenaemtotion sh tnak Funuion is_invoked + la function ia made viatual to achiewe Aut = [time polynne rsphisnn« ee = Every clay Hat ures wuual Ginctions has its foun (vivtual table. Te ts a lookup table used te wesolve Fanction calls, Vioruat pointer iso pointer, aoe points + the foble db function pointers fe. Viable. is a | hidden deta member to atl those ctais cahidh has viewed fundien Base class> Bind vToble - Wintual eat )4———p eat) | > Ftyg=———_F Fg) | [| Beivedelass: sporrous__—Dvived class : Cagle | pet] [eet : { Table oo vToble _) - — |_ eax 1 = AsAinclude cbits|stdehs US 0 mnowmes pace Std5 “|class bird g ; a tau) Niue Cour ce" bind is casing Neca; Void Pye cour c “bird is Biying" candy 3, 5 —_|elass_spansour | public_bind £ | Upublics noid eat) & tam age wuk ce" sparveoin 1s easing," ceed! void Ty tit oi scout ce" spaioun 1s Figing sez endl; B35 Public: votd eat OE __couk ce“ eagle tis’ eating." endl; a 3 void fry re ws “eomte is Frying, “ceed 5Lint main ()¥ | Migectel | | ~ bind ™ bind| = neu spasurow () 5 7 _ bind! — eat); __ binds Fly o); bind * bind2 = nun eagle O); bind2—> catl ); 7 = biad2 > Fly, basay u : tal I pasrour_is eating. a (9 ao aale is eacting = bind f Fiying a = = = Constnutkons Camnot be mode virtual » hen > Char, is _execed, there is mo vTable. in the 73 ibasemno y+ . a2 Also, constauctons have ‘Some mame as clon i nome: TF we make constructors Virtual in - hase Clan _, tk means thy ode ne- dened ow a» overt iw_chi bur we ! ONS So, a2 __|noume fog two Clay I-Destuuctons com be made Vistual, One of the IsMearon is VvTable i emt tn mm ak tne Hine dh ewAueien cain : ae Es 1Bu4 asin one clam “dertyu ctor Vijluol, y last emaures Hat denived Clos dleststictors axe abso calied abide prenents memory leakage» Othenmise if hase clans destauttor is not virtual Hnein, base clam dutructoy if cabled tahide midst lea to_murnony, Veak So, alwoye make bare clo, Autrey a3 lvigawal . : bn) bw Code 5 | teinclucke cbits| stdctt-h WIN nomerpace Std, ¢ nae. Class AL Pwolie: AL Cour ce“ ckose AMLc endls : : = via “ALL : Cource dtos A" wondls:2 , ~ ined / i - 3 leis epublica (me ae emai ET ay |. ___publie: ee - iS Oey oe es et P coukccScton @ ec emdl, ein = r= eet aoa iS coux cNdton BV eeendly eo = 4 oe Pe FS fink wang STEN abet shai i A * oby| = newt 85 : “ _ A> | ddlete obyl; J = Se — es = Ss 1, XA _ 1 om Uror B __ _ _ akon @ a dio nA SOBSESSEEGEUL: TE bore class destauctoh “tos nol made. Natal _ Haun ourput will be - Clon A — aston A Tn that cose, derived clans ka destructor cath nahi hota. eds wONS~ = 3 | _/ = bess i = _ = _ _ _ Ba <—: [Showing only esentia) informeadion : \idi h a Seat “ things = a —=— — — — —— — Be |Abstnaction ts the _supee-s sek of the othe == ion, nheritonte. tamed) _polijnoxphiata thee pillars of 00PS ives emeapsulod = — 7 ay = io = - la > eval Rime An Foncate base “clan _\s_a class thet= comnot _ be instamtiated ive: absinact class Ka obyect a lel abstract clans if it Contain’, & Jotleast one pune virtue) finction. _ [pered clarses that inherits fa0m abStuact bare. clas mut provide implementation fox its _ _ | obstiacr functions ov methods. _ a Is a funuion that must be ewiden,_ Ina > derived clam oMenwise that derived class will L> abyo become on abstraack clay + ee [> SS$b | vidual Noid func ( ) =include < bits |Stdett ho a wring. nomeapace Std 5 Clogs bis Y publics Winitual- void eatl) =O; virtual void Fig) 05 y- clans sparviow ? public bind PAivate: oid gate tout <<"spamous eats "cundl, void fy OE Cout ¢< “sparrows Pin" eeundl; clams: Piqnons public bind f peivotes elorees ' Noid eat LE ne Coutéc “ Pigeon. eaks"ecemdls noid ty) & cource Spigeon Ties" ce end); int_moinl £ bind Kbirdl= hau pigeon \); bind eatl)} : | bind * bind 2 = “neris sparrow) + i | Pigeon eats een a [spinous fligg = }Code S| teinclude cbits(stdeda he bail Tt _ | wsing, Namespace Std y | access private membeu of class B then it fsdend keyword is used te ayamt a class On function, access te He pitivette amd protected members of Lamothur class _ Le 2 cwamt that a clay A cam be able to Cam be clone using faiend Rejword:» publics as ACint x): x(x) £4 7 int gee C VLoonst f _ ekwin x 5 —_ Fuiend clowns B- [= fiend void paring Const A &)-[elo BE public; ea |___weld _ paint Const A doby)X cour ce obs -x ceendly vi | | | a | | ei St — poe uv | _|_veid paint Const A ob )e at cour ce oby- x ecendl; — u vos | = int mainl )t _ : C A obit (oe); s i @ oby2; tt no : S| ob y2.- print (obs); [calling cla a ie print Cobs1)) lo lo SOVSEEOEESEEE EELSYes, Constructors com be made private bus oe com's creake any} instance of thot clos cuhose Conatnuckow is made private clas aL ink x5 A Cint x Lh ens) cn amen heen Tn the obove code, constourtor is private amd ths code will not give ony compilasion erunye » Ainclude cbits |stde +4-h> Using. amespace stds, int x; int 45 eee ACint x, int 4s x) yy) t meal | a clant AL : ; = : public : int geex OE sarkwin % 5 ink gex7C) € satu Ys Friend class 8; by rr___pwvlic: _ = — | A Fane Cink x, int ye serwnin A Cx, 4); un : : \_\ i tsla'y ena | a i fine man) t_ — _|Tn the above code | 8 eby ty — A oby2 = obs|: func (1,2) Cou obj: gtx Dee" “ce ob 2: git ( Ie enndls clams A Ra const nuctos. parlvare inal «So, fiend claw brake claw A ae private memnbers ko accu ka skte hal. Nha clay 8 hai friend ts chan A+ So, clas 6 ka imstomce _crrate kik: class A ka instanu, Creare ka shie hot + | Tatine Punekions Taline functons ars optimisation Rarune Just od mates: In inline function, the compiler places a copy ds the code of that function at each vha_ Se point wher, fincHon is called ak compile time, crekumtype Make the fun ch on intine | fune ©) €| inline only if the code I code [etonion is only of y one or two Vines- cs cs cs if BZ 3 IN Aga tmnoion tnline h to colt hone pe Call stack m entra ani bnegi wother thon vo ek Une ka code. tha se [eodk aaigh bh whe copy, he Jayega. ob compilasion fume:
You might also like
Chapter No-02. Functions and Constructors.
PDF
No ratings yet
Chapter No-02. Functions and Constructors.
27 pages
Oops in C++ INTERVIEW SERIES - 2
PDF
No ratings yet
Oops in C++ INTERVIEW SERIES - 2
24 pages
C++ Hand Written Notes
PDF
No ratings yet
C++ Hand Written Notes
15 pages
OOPS Handwritten Notes
PDF
No ratings yet
OOPS Handwritten Notes
20 pages
Oop Practical Manual
PDF
100% (1)
Oop Practical Manual
34 pages
Operating System Notes Compressed
PDF
No ratings yet
Operating System Notes Compressed
85 pages
Java Unit 1 Part 2
PDF
No ratings yet
Java Unit 1 Part 2
72 pages
C# Topic 2nd 3rd
PDF
No ratings yet
C# Topic 2nd 3rd
36 pages
CPP Programming Notes
PDF
No ratings yet
CPP Programming Notes
80 pages
C++ Notes FULL - Compressed
PDF
No ratings yet
C++ Notes FULL - Compressed
176 pages
Unit 4 - Trees
PDF
No ratings yet
Unit 4 - Trees
162 pages
Computer Programing Lab PDF
PDF
No ratings yet
Computer Programing Lab PDF
105 pages
OOPs RAW
PDF
No ratings yet
OOPs RAW
31 pages
Unit 3 - Linked Lists
PDF
No ratings yet
Unit 3 - Linked Lists
92 pages
UNIT:1 Þashath: A Pupiam
PDF
No ratings yet
UNIT:1 Þashath: A Pupiam
49 pages
Core Java
PDF
No ratings yet
Core Java
51 pages
Inheritance Chapter
PDF
No ratings yet
Inheritance Chapter
35 pages
Multipleinheritance ObjectClass
PDF
No ratings yet
Multipleinheritance ObjectClass
14 pages
Unit 5 Signal Conditioning
PDF
No ratings yet
Unit 5 Signal Conditioning
61 pages
Unit 3 - Relationships
PDF
No ratings yet
Unit 3 - Relationships
23 pages
SUMANjava PDF
PDF
No ratings yet
SUMANjava PDF
496 pages
Adobe Scan 21-Dec-2024
PDF
No ratings yet
Adobe Scan 21-Dec-2024
29 pages
Unit 6 Actuators
PDF
No ratings yet
Unit 6 Actuators
57 pages
Oops
PDF
No ratings yet
Oops
21 pages
C++ Short Handwritten Notes
PDF
No ratings yet
C++ Short Handwritten Notes
25 pages
C++ PYQ Programs
PDF
No ratings yet
C++ PYQ Programs
16 pages
OOP Prelim Paper Solution
PDF
No ratings yet
OOP Prelim Paper Solution
27 pages
Java Notes by Ashutosh Sharma
PDF
No ratings yet
Java Notes by Ashutosh Sharma
20 pages
Adobe Scan Jul 01, 2024
PDF
No ratings yet
Adobe Scan Jul 01, 2024
12 pages
Imgtopdf 2909221401056
PDF
No ratings yet
Imgtopdf 2909221401056
39 pages
Oops Assignment
PDF
No ratings yet
Oops Assignment
11 pages
JavaQbank V2
PDF
No ratings yet
JavaQbank V2
16 pages
OOP Practical
PDF
No ratings yet
OOP Practical
30 pages
SUMANTH Sir.... J2EE PDF
PDF
No ratings yet
SUMANTH Sir.... J2EE PDF
496 pages
Oops 02
PDF
No ratings yet
Oops 02
25 pages
C++ - OOPS Part2
PDF
No ratings yet
C++ - OOPS Part2
10 pages
Oops 01
PDF
No ratings yet
Oops 01
16 pages
Rupkatha Bhattacharya, Roll No - 03, CB303, Assignment
PDF
No ratings yet
Rupkatha Bhattacharya, Roll No - 03, CB303, Assignment
4 pages
Thabrezali 23bis057 C++
PDF
No ratings yet
Thabrezali 23bis057 C++
10 pages
Unit 4 Module 1 Lecture 2
PDF
No ratings yet
Unit 4 Module 1 Lecture 2
25 pages
CPP Notes - 02
PDF
No ratings yet
CPP Notes - 02
30 pages
Java Focused Short
PDF
No ratings yet
Java Focused Short
28 pages
Unit 3
PDF
No ratings yet
Unit 3
22 pages
OOPs Class Notes
PDF
No ratings yet
OOPs Class Notes
10 pages
CPP Notes - 03
PDF
No ratings yet
CPP Notes - 03
30 pages
Opp's Assignment2
PDF
No ratings yet
Opp's Assignment2
12 pages
Java Assignment-1
PDF
No ratings yet
Java Assignment-1
17 pages
OOSD
PDF
No ratings yet
OOSD
20 pages
3.langmuir Hinselwood Isotherm
PDF
No ratings yet
3.langmuir Hinselwood Isotherm
9 pages
Assignment
PDF
No ratings yet
Assignment
5 pages
Unit 4 Module 1
PDF
No ratings yet
Unit 4 Module 1
27 pages
SUMANTH Sir.... J2EE PDF
PDF
No ratings yet
SUMANTH Sir.... J2EE PDF
496 pages
LL 04
PDF
No ratings yet
LL 04
16 pages
Java 6
PDF
No ratings yet
Java 6
32 pages
笔记 2023年8月21日
PDF
No ratings yet
笔记 2023年8月21日
7 pages
JAVA Middleware
PDF
No ratings yet
JAVA Middleware
34 pages
LL 03
PDF
No ratings yet
LL 03
12 pages
Oop Assign 3
PDF
No ratings yet
Oop Assign 3
5 pages
Midterm Cheat Sheet
PDF
No ratings yet
Midterm Cheat Sheet
2 pages
CPP Notes - 01
PDF
No ratings yet
CPP Notes - 01
30 pages
C193243 Cse-1221 PDF
PDF
No ratings yet
C193243 Cse-1221 PDF
28 pages
Classes and Objects Part1
PDF
No ratings yet
Classes and Objects Part1
25 pages
Dashrath Nandan Java (Unit1) Notes - Alasso
PDF
No ratings yet
Dashrath Nandan Java (Unit1) Notes - Alasso
11 pages
1683044825934
PDF
No ratings yet
1683044825934
5 pages
OOPS Notes ? - Removed
PDF
No ratings yet
OOPS Notes ? - Removed
20 pages
DocScanner 30 Sept 2024 2 33 PM
PDF
No ratings yet
DocScanner 30 Sept 2024 2 33 PM
12 pages
Oops Notes Curated by Sameer Raza
PDF
No ratings yet
Oops Notes Curated by Sameer Raza
21 pages
CS201 Handwritten Short Notes (VUAnswer - Com) Handwritten
PDF
No ratings yet
CS201 Handwritten Short Notes (VUAnswer - Com) Handwritten
13 pages
Oop
PDF
No ratings yet
Oop
20 pages
C++
PDF
No ratings yet
C++
22 pages