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

C++ - OOPS Part2

The document discusses inheritance in object-oriented programming. It establishes that inheritance allows a derived class to inherit attributes and behaviors from a general parent class. It also explains that protected variables can be accessed by derived classes while private variables cannot.

Uploaded by

onlyforytb123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

C++ - OOPS Part2

The document discusses inheritance in object-oriented programming. It establishes that inheritance allows a derived class to inherit attributes and behaviors from a general parent class. It also explains that protected variables can be accessed by derived classes while private variables cannot.

Uploaded by

onlyforytb123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Custions based

estab lishes a nelatios hip betw een


(aD Inhei-tan ce

b) base class& doired clas


aboe

fo estallsh a reltionship
betuten object
The helatons lip betsten a zeueral class ad it s pcialig.ti
a

an inheritan ca helation ship.


2)Afiad furction inkenitd? no
Olepeads on inhetknca@ none
No,Yox Cannit inkot a yhiend fnctin in ctt. 94
suelatinip betstn too classes.
(03) Mow'ae Protected variables accesible om darired clao
classes
Paivae nhesitan e 2
cannot be nhenited
photected Variablespsotetd
nleited as Vatiables
nkenited as paivate vaviables
,e

chong thon t w7)), be mot alfedd


mboth Casee.
(0) Turo cleues are indupudt ol eachothes.
eToo clases ae
) alolthe abpve.
Man dis advantage o wsing in hoitane i that fhe fo
Exgl'- This ncand

iatt ore canngt be wed Tndependont o eackch her. 99 oa


changd thon ue
oThe (2 (Os)
OFaicada
initializetheto
Valut aaneuer paiuae clasAeL
pemo
das abjectany om cla
Pemo) the
lCoustutos
declanaiaberd menb
o<
casdesied
the ene
iutializatn. that clas
asiganaaa with decdared
theca
to pntteddeid
that
pubie
meabeaclaues ahignally as
Demo()
Demo ctt, aypettedacce public
iisatim publlei chas c doclared
membem
these DATE: PAGENO.
wbich
Coast that
declard Can 120
uctor ass alo be
Declaed wed
clelrthe fo hane testthie wsed 23
here
kene daly byo
’ "
Demo
dassziosteam
inde
Costntor. " and
demo;
leme main) id ’laiamtied enclesedConstto
an values Thoseentities hen
3. Demol) olong Lame
Ranete
inti; Constucto ganbage
oY t Constoto
Constuct
Yandem otities be
donst
withinthe eme
values
Outpt&oD hae necded
valuest name data. /

dau
ganbyevalueeated,tu
Cawe

dass
Demo
notos
teconst
iostheams
#incde
Conttu
Jolasamiei
Constwctone
bni. zed memony
(Goo0);
Cout Demo demo
Demo main()
t d Angument
/seting doject indnan e
ee Demo(intva) agumat.
-
demo. demo val;
paramstrited2 entties.
(12009; are clandawthe
t
<endl; pased
hae. to

values with
the
class ciosthea
Dema #icude Lopdata The haenentase A
Demo publii mudtConstoCondpy
d2.b, b lemoliat DemnC pivate Qomo d4
hile instantiated
obiet
a,6jint (d);d3Demo
the pena
Contt
Canstucto d2
Peno al, ollaang can
d1: =
int be as
ddÀ b1)
cranpl dent passedin a
Meus
all obiect
ahietand
31);
lemo d Pemo Demo int the mulipe
Demod4 d2=d1; paainat
C)
d1ob=" hetun a DATE:PAGENO.
dl, d1(
Cagy A4TGoLD
"e<d,
a=
2o
d Guou,
ways
D); 6
Constito 20

ced2ogetA()

but (27
" " "
. gn "A "Must Consttos
Constudo d3.o
50D0,d2az
ceate o
Agunat at calA led tlis Costucto.i
Constuctihs
anevinlual
Construtos Cannst
erpltymenbens,objehdalault
deault and membea
Cas, hane a ts 5v,
lasemeteiaed menbers hich havethe
Can Cottsuctio donot
the as cannst are eme d3o66oDD d.b
tiitalizes Censt ction un
be , soon uoto
Cont =
teiel hat hucteh inveked auctcanomat Aame must 6oD
as be Rave
passed be
Cnstsu even Athe be
wil so tt called at. clly aaYaMetheasthe
to o the the istal, netn
costn be
inportaut paraneters.
erpüity dame
Constntn
kMem ber
tos, an otas
he provide aoemembehs.Acta ct called
ction.
orun dt Constructon tine.
in but
paramtized Ct yp namecaubut
t oyCheted o thee ohen
simyy deu the
wiyng object whera
coutucas
deaut which an name.
adl itaieton a he cles a
conttnuctv doesnt caetom no
coustuctas. Constu oecti. functou
captCan
antes
o toy take autwat
is
Te Chated. wked 4 We Whea
Aat faanitehA
(class-nane
dasname )
initialecto
can
Lenpilt
lakes concept
ao
menbes.
ipeüa nlwea to
pziidea hae
Coasthotuor fnitialize s
caled. mose
autt Cautacar
avealoadig
cousthutoy hen
thatil!
CAeated. be he
one
Vati
values
bwhen ous Castctix
ag DATE:
PAGENo.
date
outhucti
in J20
elenent a
clas
to aad
all
#ncdeiostrean
mainl(3it Coutce
Privates
y J.
un
hot x Cout
ggto lbaplasta()
enpy
callto
ce"
to lanamsteized std;
call call Constntoy deault
ayparamoteri
Constuctos coutuca
CostcCoustuctos called costudoy
ed
constr here
hore caleJ
hese
ctos ccendl;
(A
noth hene here

way
endl
doig
3
s)
Fox Cout
LatanctOutput happens
epratoy
Canstuct
Constmdt
caled
hetcalledbessenized apeaatienhaqus
yalueshotey
h
Cousthucta

Constuctahl contucta
Contnctiy
called
called contuctoa
kene
caled DATE: PAGENO.
only
aignment ony J20

atignmeat
.Thi PelautCo
clashich When . Costu ct
Comyilr Does
Membey
Vaniablesdby we
wil do ay
doescheate not
delined
Wser Coutuct
clate Docs
constctos a
meniber
Meney delaut ouY

doer
-
wise
Co
py
shallo Const
Vaiables
Menber constuctos.Ctf
Dbjeet 2 bet
cen ctos
bbjedti . o
Cach
Labiet2
eeyyaN
abes

Lomvesißn fdiidual
ng
Convcáibn
Coututoy
Coavehsion
Lauttas
Jndiriduat

Lwe Lanstuctodoe
Pseplata(it
y,ást)
Cen we
Can DATE PAGENo
Cen M"V
object 2
cal
JO20
Creted
cotcty call
constu Ceneuty
Individ
by ctox

You might also like