Constructor and Destructor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Unit-TT Parpt

Constuto
psteucto
6_consbucto 4pecial ntnben
the las
as hat of
wtd imutiaie
lues tu
Na tie data
eXected Qutomehielly wheheve
pbjct las corec ted
Clau claname. bay ab
public i
publi
Aata menba intaj

Cenatrzcet'
Constzucto
A conafucte as ame hame
to hich
A constucto ereceted autonatiely
the ela
CAated"
"A coatucte does not bave ary uetun type
not insi cle public
seton:
onsucha ae detned
ConleuctoL

CostryteL
Paçe No

(en tauct ant


a) Aelault Qassed defun
Cengtucto

tindudesistuGm h>
ttiachude<Conio-hz
clas aicctongle

fublic
Maain
entucter
tiet cdec int
benadth, ingth it
HuClangle
cla
<canio
hztinclude
ther tme the atNalues
inttialise
d Bnsun (Ornttucte
hich constaula epaamei take
this Cenitute
auter patameteed,
it piaible
to
do
which conabucte
faametuijed
(Date
NPaa
cout<r n
qutth);
utusn O;

|z3o
Ahua

conutuete whum
the Volue ol a
the

demo bb=
dens bblaa)
tt iaclude <onioh

imt a i
pubie
deno()
7

¿t nA

M bjat t a

deme bhc aa);

puttata(
abputdata);
Bunt t
etimO;

Autput
'Cheatad
Nutbu'

dautmigd

f
Page No,
(Date
!20

new Can nhexit the data


land memke
and also odd membb
meu
Thi PHeleu CHedting
Base clas oho hnown pasund
clad
Aeiyed elas ako knan alphild
Aubclak
"The main oduontagr of inhenitance
clas X
MenbA Bese claw

Menbe A

{Mewbea B

Leried clou duclosstion

doed clas that h t the data

adding
dos eued.clahame's Aces spoufe bot.ca

fublie AB

modhin)
tt Data mernbes e membeH tun d basc lau
1Bivat Rrctetid Lublic
wat Ksivat
X fuotectJ actected
ublic. frotetid Rublic

G- Bae class Eqised cls


clas abc clas
ivat : a.b ~Jato membc livat! m,n
fuotetd,d
fuseigetdata C)
adata() enbe Rublieiioput)
funtio Butput)
X42 Piyati abc
3dingle shetonce haersciat
i ) uttp hheitane
iú) Mutleel ahitance

dinge isheuitanie ngle iahexi nes


fuitancia la i dei
ne
base clas.
A

8wedAuved das
additon tuo

iadud< cniosh
as A
Luctetd

Gnte

iat
(

veid qetdaa ()
Cout<e te n nten no.)

catn Asditua = z t j
int maia)

B aai 2laa)ejut las

puddata

)Multlel iahetanci t i abso


todoiuea clas
sem exotine_derived lau
lass This
oinhettane
dexined clos.
Base Cass A
Pane No.
(Dte

#mcude<jos bieom h>


tnlude(onioh
clayA GAtta ma
et spe,.
ablie Ymashs
yoid gtallO
at n Eno oll:

In Roll

Lclou .Al A
Rustectad
iat subl subdi

taut<rh Mas4="
Par

int
Jabll:
vedt
caul<n Ent spont masi
Noid total

put mauh
Jotal hashi ubltsubt

t mainU

C aa;
DMulaple Snhesitarxe -hn dexued a can

as onuliple inhexitance
Bae Base

ts
(Date:

clau de¥ved. clau nane Acces

include<iotueamsb
t incude<cogiohz
lan AA

A tee
int. fublic
Nod iapt

faotetid: fabli
Pubei
Void
gedlatal)
Cact
Entr no
=50Additiem
numbero:
Duteut
();qetuh
Hddition
qetdata
: aa.
aaj C
main int
Katbj Asddiim <ln
<<
Cout
addilin) vÛd
cdd.|a, Rublic
att
publi
B. pabl
A,ic Lauli
oneldats
) IRukic C
20
Dab:
No. Page
PueiAc lB
oss
ntei elttome <<ln Cout
putic'
lneam
he sios iode A
closs
B
A
class Base A
ical concept the
las devived ultide by
Huing base One when
Snhvitona Hiexaxchical ig
Paqe No
(Dat

nide clau Bi

class Cfublir A

soid puddlata ()
\n Snaide class G:
3
3
otnain

eleme to sahitance
welceme
ceme to Sahtancei
Paeo
Snhuitanc &
we combine the conLetu
typc C
muÁtiled nce
hitraschial
inhoito snhoita
basic
sahexitance.
hes typc Aybsid
a inhesitace
to

mabiple

includs<iostaeam h
tincuda <coniosh>
closs A
f

pukici
void puddata

clau

Noid
Page No
(Date: 120

coudsen Snide cla g:

ublic
void mOsage()

Qublii
Noid púntO
coutk "ln sraide elass D'

igt mato ()

Dddi Tnide clas

ddo mesae
dd putdlta
Poceu aiting.
TheOCES
victudl iboiting
at oni
memkoy wil!
base a
deied clau
and coepording calledáHtaal Sohe
Ahand bae cas
calledNistidl balecla

public

cla chik:

clas

uclude riutam-h
Everireen
Faço No.

(Coe 120

The poceu inhutng


intoiting
victudl hat
mémkun wlcalledabbeaintal sahexitd
dexived claw
and ceeCPordling, shad lase las
Nihl
called bae clas

|fbrent
|Chld

clas
pualic tndnt
las

clau

timclude<enio-
clas student h
Page No
(Dat

nt oll no,
puble:
oid qitolno)

in olno;
3
VoidahouHcllnol)
cats \n nal

protected:
t at tet 1, teat :
aid getot)
ot< enter test 1teat
cins> tt1, test :
void Ahaustutl
<< tet ;
Cout e|n teata <« test a;

vi;lial tudent
public
void qlacoe)

)
.<<

dan total'pukli tety pukiu dpoit


publie
yoid shewtotal)
t= tuts ttest&tse
Ahealle)}
aheutut ();
Ahawscere);

oid main()

t
Evr
Page No
Date

getacsne(O;
tl. shewto tall

You might also like