00 C and C++ Essential Hand Written Notes
00 C and C++ Essential Hand Written Notes
00 C and C++ Essential Hand Written Notes
S t r u R
Ote 2.51Tutzoz
Page..-
C and Ct Concept
maun
(od e main
a[s1=703 Se
Pvint CaC21) > fo
be cause ato] was initiali zed
Daint (o
int Dmain O
oy
G
aLcessing
StY t -
MembeY
(D01) apevodto
lenthz S
1SuSed Maln Memo
Deftrinq Heap
Omplex Dumbex án stxudtuC
Caxds ACe
Fare L2,3 10,1 K, Q
Shape ,Q42
Club
2
spade
int maio U
Stut COxd C
fare
Shap 0
olT 0
card C21,0,0
stauct
]o-or long un sfgn ed I
Date
Page 25.LUbo
nt Main ()
StrortCd deckIS21
fori0iK52 itt)
Couet fate
Cin 2 deckLi]-Eate, (out<Sendl,
Cout " Shae
in72 dec kl] EaLe
Cout Sendl coloy
ciO >2dec k[il-Co lor
Hoc Ci 0 KS2itt)
Cout <Tdeck 7. fcace <t <S deckEi) ghape <<" " ( dectTl
colr
X t ut Dectangle
ot lenqth
int baeath
Ctd chax X
Stouct variable
declast o4 globa
SLut ectanale X
int m aioO_
FOr long unsran ec
lsizet1));>Prin to 12 in stead ol
printf ho been oJoted bytesosteadC onaO i c h
hatrater
rt scottotmerThi sTOTN SPRdtthTPpateting
oemryisdahelbetz other wo ho been_Qllhted 4 bertlA tberumel
hounoly 0 oullo t byted to Ch ar atter
Pointer ok e 2 byte r9allot t etus n void poirder
Heap memor y
Poin tes Adldoeyvaaiable
PsoqamCsenuenite_inaixurtzcoLin pxoqz.amming 44
aniqw h d _ a Lnthp ncec to exeLl
Can aces) only_code
Star
st ack Section c memosy o aLcess
0 an
extena Heap ard extexnalxeioUaces,poiniea is M ain
Code
rsequided
MeMong
Uses
)Acces SinG Heap
2Accessiog_anu exteana esUBE)
padametes passing
int P:<dedloration
p &ain ttializing
printfhd tp) <deaefoenting
o allocate Heap menms brny tdlib-h~
Ftle
Malloc
fun etiun >
fnt P Co ecting
linttmallocl5*Sze Cint));
p: far heldy n Hef
clement 1t co
Laoy Si2e Cno
int pointe memon
DE newint L5 fox (tt
intalo Statk
Íntk=a (S+0dk
i t maioO_
object
Creating aaiade cB tupe o stauctuae dunamically
data type
in hea0 DSiog otntea
Staot 3ectangle Kp
0rCp (strut aectarle *)malloc (size c Cstouct Rectoungle J
fo
Ct p new Rectc nGle
p length =10 00 CxP):length =LD
P Doeath S,
mon olit h Modela O
Poot e d u l Prog m
Pro qOCM
int main () fone C)
3
moun
>Functiong
Moun
'nt Y2
y l0 epervrnsrete
2 addl y);
PYintlz))s I
3
tunati on vabiable dies a soon contaols
setoinsdomfunctioo
tP Pevehenin
Poi nte takes bude
clont (cuhe any yyemor Date
A eence Page2202(
Paxametes passing
uitabte OOetUOTDinu the oesvt
c a l Du values tOamad pabam eter does Ddt affet
actual PaBametev
erc ieloetuaalna-rerethauavaiiable-erthanging-attoe-Prerde
call by acldoesS Aoy change io foamad paramete
atlect actual padcmete
ode Th ptotrdura he
Uthough the SoD
Calbu dPedene_xadham S monolui okile (ormplng
becz aJ Soon as Swcp 15 Cdullecd i becomes Past c rocin hned
yEtemP Ma
3
ot maio)
R
al
20
Do? 203
200-2ol
b 20
Suap C b )
prI Ca b)
Pointer in tes (ompilex take) bufe
We mnn ot ufe fbx
sinte
cach loup on Pointex
P212
int F_ pP
p Cint mallo nt Size dCnt));
eturn (p)
int main O
int xA
Complet e adoo in Stabctuse con be corn pl elef
PS Cven by Gall by valuc
yDate.
Pege 2h21
Stovctvae a Panamele (Ho func
(tovut kectanqle K-
C
n t aoRj
a a ea (Y)o
pait(Cl
XCalL by ReBeaence
int main is SCume
Call byaddaes
YtaidfenLstauet (Name)
LEYD
VOid funCStsu ct RECTAVaLE
lenqth tti
bae ath ft
3
iot main ()
i stauct Rectangle x=t10,1
funC1)
Stsuct dectanCle 1f
x = nec Re ctcnqle OY e6tret Re ctaungle
Mcultoc Csize t et
Retaqe)]}
new Rectanqle C3J S to orde 3 object
dada type Rect angle0 heap Me o
P Date 3/125
HadudeKiastaeam~
Oinq namespaLe std
ass Bectangle
DiNade:
Int length2data membey
hot boe atb 0-Rectanqle cass 2
publi
cOn Rectanale C)length=bae cuth=1,2 o defob
Constcto Paam stesized (onstr
OveToaoTTU Rectan gle Chnt 1fot b>
ot Cse at)y
aclatotbu
a tcessoY Or nt peaimetex )
gte fundnak cet lenqth ) retua o lenqth,
mtato er tun iuni nt setlength Oi lenqth:3
Deur in Rectancle )
3
Reclanale:: o Rectanqle
ot mauo)
Rectanale 10S)
COutK3 peadmetey )
Setle nath C20)
Cout 4T-qet len ath)
3Wouo Dectvueta w bealledand t detroug
Recd anql object
Scope Rejolutron peratrv Date----.
Pege.3.|al2 b2
lemplade cla
knenenitttatt
henedic Class9 Suppontb_all cl ctta tspe no datatsne
rebtriction)
templake <class I Scope
endu hcuC
classAta Azithametic
2paivate
Ta-
bi
public
Axthmetic CaTb
dd
3
Hemplate < claas 12
Axthametic Ki) * Adith mauicTC b)
tas Auihct
this a a
parrnefer
this b b
n t Main )
Thetis en plate declaxinq