0% found this document useful (0 votes)
16 views10 pages

OOP Assignment No 2

Uploaded by

abhirajkanse1677
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)
16 views10 pages

OOP Assignment No 2

Uploaded by

abhirajkanse1677
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

Assigmer 2 Page No..

Date.

Exploin class and chsject ut exomple


Ans Closs 2
tha
A class in ctt is tbe bulding block
objeet Gnented pxoqacmm/ define
I s a Cetinec
dcatatipe cahich halds t Own dcta membe ss
and nembes unchHons

Consicex the class of Ca hee ma


emany o_oth odfiren mames boand b t
all of hem all shme SomeCommon ropeaHes
ike o of hemCol hve wbeels Spsed
limt mileae ange te
An obiecd is an nstenge ot a Class
ohen a class is defined no memmy Is allowed
but all o hem I S instained an
obecis Cecked nmemaa IS ollecched.

wle a proqmam for cleiss sudent toth t s


oembe tuÓcHOns
Ans Enclude cshdio.h>
indude Conob>
Ueina namespace Gtd
class udent
pavcte

CharOame 3 0

o per (ATCOP
Page No.
Date.

Public e
NOid ge Details yoid)_
Noid put Detals Void)

Noid shuernt. qet Dehals (aic)


Cout <" Enter name:
Cia > name
Cout <" enter ollhumbea:"
Cin>> yoll no
Cout ec entex deal makS ad of 5od "
in>total
perCfloct tetall500 l00

NOLd Studera put Details CNoLd


(sut ceStudem dela1ls:\n'_
Cout 2 ' Name"2enome ccRoll Numbe
ecallno sc"Aodal"ccotalcc
Dexcentg e CCperC

Shudet std lla


int n loop
(out cefoter dotal no ofshudents:

for loope0 loopen;loop tt


Coutc"ndea detals of studert. '
cclaoptL (ATCO
Page No..
Date..

Stdloopqt Delails ()
Cout ce end
fo2 (loop=O; loo p <ns looptt
Court <c"Dedauls of studentzcloop1)<c"\nD
Std loop] eput Delails C
etumO

Oukput
Ertea tctal Do of Stucdens 2
Brttr delails ot Studeot: L
Entar Da me mkey
Entr ollno-
Lnto total mores out of 500 50
bnder details of Stuclent 2 -
EhHex name u l l
Eoter oll no 2
Ene Aetal morles out of 500-YSO

Dohails ct studeot L
StudentDetauls
Namei-Mikey Rall NO2 tetal -ysopexcenHagega

Delails of student
Studet Delails
Oacentege o c
llNonneJully Roll NO:2 toteuR

(fTeop
Page No..
Date.

bxplein static data1Dembex, GBadic membez umeta


Ans DStatic daBa member
Usia-
Ale Can deline chss members Sletc
StiC kequocxd. All Sletic daBa is inili2ahed op_
2e0 0hen the hst obiet is CEated , t I0-
othes initili2e o 1S phesent
Static membey tuncdhions
Membez unchions may alSO be cleclcaed as
stehCtertic Membea tunchidn haNe access a
Only aher Stedhic oembeos dedooed in A
ame classthex clonthave q his pointee
SHaiC nembea tunchion Can be Called USing
n e Closs ame

Oessaabe toith pmoapanm 2 iend unchon


fos To object colentd pnilacummina0 tàend tun-
Crion ho i'soriend o ogNen Cass i&q
tuncinD hc is aNen he some aCcessOs methods
o piNate ttecte d date.
Neccds ot tsiend functiom-
As the pioe membeDS Cannot be accesseo Om
trom
outs ide the class.
o Thot IS OGnmembe fumcton Cannit have
OLCCeS to poINaute clcta, Cass
o That is mon-meaber unction Cannot haNe
access0 6 p i v e olerte, clasS
Simpy deloaehis unction asa miend
of the
Class cSi
Page No.
Date.

class Cs
classb ABC

public

iendNoid xyz (Noid)


3
Ea tinduoe <stdlid.h>
indude CioSeam.h
usina Namespace SHd;_
class sample

int as
unt b
public
Noid get values O

O-269

5Whor is o of objech
Ans DAmayATuble ot p eClass 15 knowD
nown a
OayOf obje
Tee may of object is on ueer detine lerh
T6 recdence then one abject of a pticu
he oncept ol coaay 15 (ombiped tolth thedefiotog
he class. (ETCOS
Page No.
Date

Detine he team canshu den Orth ppaooalD


ooonm
Ans onsuct is defined decaxed as
HicludeCstdio.b>
tincude<iostream hy
Cla Ss ctege
i n t mDS
publics
oten (Noid) llconshructor delared

inhea inlegcr (void) constuctoz defined


m-0 0 0

When g dlass contans a consudar ike ho


are detined above 1 quantec then an obiect
sected
Csected by he ane class coll be LnHiized qule
mahicallythe oleclmchion integea t bjecs
Creaed.

7)hte a noe on dupes ot onshuctos


Ans he pes ct Conshucones ne
hyDef aut tonshrucho
L Paramdeizod
opu
ATCOP)
Page No..
Date.

wJConshuctox sith delault onrqumerts


NONeload tonshurlos
DefauH Constauctoy panameka
The conshucteb hat aepts no
called as_ defauH Constauto3. The defautt (onstructo
usec s
usec pex example class it Is A: AC)
u) Payaetoizod Consrucdoxs-
Ln poachice ma be necesscay to i0tal
he corious ccta elements ot diffexent objes
Oith dif forent Nclue when Hhe ac Cecrhed.
calleg
Consmucdes thgt can ake qumer C e
pramcteizcd Consuctears
1(opu Conshucox
COpy Constauc-o 15 usedo declone
ct he Same me nH-HalizeOn obje om
oncthe dbjeet
ComglesC) O :
OR
Compex ( a ) :
aeference
A Cop Conshructer akeS
obiect of he Same lass
Constucher otth deauH qun elH-
)
i s Possibleo define CanShrucfe e
default ouments
fox ea h e (onshructox Complex (OCan be do
he defauH Nalue by the
Image IS oZe-
csslgmert \mge_is
hemhesitdem e
Page No..
Date..

Expkin multiple (onStnuchox io a (lass


Ans SAcla9s Can have mae than e ConShuctoz in
Othe wOds_ a e CCUm Say that constuctor caD
oe ovealoaded
Uyy usinq this Concept n padgaum Uses Can
Cecte ol thferent obiecds oth rco1oUs nctho
initialization.
a mogzam for Construccox for oefau t
eydumerts._
Ans iclucde <stdiob>
indu cleCiastream.hs
Uslng names pace Std
class Demo

privae

public
Demo

tout ccend < (onstaudor called


Demo Cn im 20)
this e
Ahis 2 1
Cout end 2"Destucher Called Cend
(ATe
Page No..
Date..

Demoth
Cout C end <e Destaudor Called"Ccendj
Noid put values(
Coutceendlccvalues af x:"Lc
Coutccendl<c"Nalues of y: "cyc endi

int main

Demo dl= Demo(lo)3


Cout ccend|<cDL value oot s
c i pu Nalues C
Demo da Demo (30u):
Cout CC fnd l<Ct De Yalue are:
dz put alues (

Ouhput
(onshucdoz Called
Divalues 0
Nolues of xilo
Nalues of y 20
ConShudo calleol
D values abe
Nalues o t 2230
Aolues ot yie
(ATCOP)
Page No..
Date..

Destauchox Called
Des bucdo called
1o hat is detucdo wth eample?
to
A_ destuctor a s h e mame implies Used a
Ans ts
oesucox the obje hat bove beLD OEale d by
Comstuctad
fo example he destudtor for the class intege
Can beoleleined as belau -
integ.ca OA
A destauctor meveyJakes my Coqument not does
tchrn Nalue
ea
mtiX motbixO

foy x lim e 0 i<diitt)


celete p[J3
cdelete p3

You might also like