eQuizShow
COMSC200Ch13Part1
ch13part1
Question:Whatisthedifferencebetweenaclassandaninstanceoftheclass?
Answer:
Aclassdescribesadatatype.Aninstanceofaclassisanobjectofthedatatypethatexistsinmemory.
Question:Whatisamutator/setterfunction?Whatisanaccessorfunction?
Answer:Amutator/setterisamemberfunctionthatstoresavalueinaprivatemembervariable,orinsomewaychanges
anattribute.Anaccessorisamemberfunctionthatretrievesthevaluestoredinaprivatemembervariable.
Question:Whatisadefaultconstructor?Isitpossibletohavemorethanonedefault
constructor?
Answer:
Adefaultconstructorisaconstructorthatiscalledwithoutanyarguments.Itisnotpossibletohavemorethanonedefault
constructor.
Question:Howdoyouidentifytheclassesinaproblemdomaindescription?
Answer:
Identifyallthenouns(includingpronounsandnounphrases)intheproblemdomaindescription.Eachoftheseisa
potentialclass.Then,refinethelisttoincludeonlytheclassesthatarerelevanttotheproblem.
Question:InC++theistheconstructprimarilyusedtocreateobjects.
Answer:class
ch13part1
Question:
Whatisthedifferencebetweenthefollowing Person structureand Person class?
structPerson{stringnameintage}classPerson{stringnameintage}
Answer:
Allmembersofastructarepublicbydefault.Themembersofaclass,however,areprivateprivatebydefault.
Question:Isitagoodideatomakemembervariablesprivate?Whyorwhynot?
Answer:
Yesitis.Thisprotectsthevariablesfrombeingdirectlymanipulatedbycodeoutsidetheclass,andpreventsthemfrom
receivinginvaliddata.
Question:Isitpossibletohavemorethanoneconstructor?Isitpossibletohavemore
thanonedestructor?
Answer:
Yes,itispossibletohavemorethanoneconstructor.Itisnotpossibletohavemorethanonedestructor.
Question:Thetwocommonprogrammingmethodsinpracticetodayareand
.
Answer:proceduralprogramming,objectorientedprogramming
Question:Definingaclassobjectisoftencalledtheofaclass.
Answer:instantiation
ch13part1
Question:Whatisthedefaultaccessspecificationofclassmembers?
Answer:private
Question:Canyouthinkofagoodreasontoavoidwritingstatementsinaclassmember
functionthatuse cout or cin ?
Answer:
UnlessaclassisspecificallydesignedtoperformI/O,operationslikeuserinputandoutputarebestlefttotheperson
designingtheapplication.Classesshouldprovidememberfunctionsforretrievinganyimportantdatawithout
displayingthemonthescreen.Likewise,theyshouldprovidememberfunctionsthatstoredataintoprivate
membervariableswithoutusingcin.Thisallowsaprogrammertousetheclasswithoutbeinglockedinto
aparticularmethodofperformingI/O.
Question:Ifaclassobjectisdynamicallyallocatedinmemory,doesitsconstructor
execute?Ifso,when?
Answer:
Yes,theconstructorexecuteswhentheobjectiscreated.
Question:programmingiscenteredaroundfunctionsorprocedures
Answer:procedural
Question:Membersofaclassobjectmaybeaccessedthroughapointertotheobject
byusingtheoperator.
Answer:>
ch13part1
Question:
Lookatthefollowingfunctionheaderforamemberfunction.
voidCircle::getRadius()
Whatisthenameofthefunction?
Whatclassisthefunctionamemberof?
Answer:
Thefunction'snameisgetRadius.ItisamemberoftheCircleclass.
Question:Underwhatcircumstancesshouldamemberfunctionbeprivate?
Answer:
Whenthefunctionisnecessaryforinternalprocessing,butnotusefultotheprogramoutsidetheclass.Insomecasesa
classmaycontainmemberfunctionsthatinitializemembervariablesordestroytheircontents.Thosefunctions
shouldnotbeaccessiblebyanexternalpartofprogrambecausetheymaybecalledatthewrongtime.
Question:Whendefininganarrayofclassobjects,howdoyoupassargumentstothe
constructorforeachobjectinthearray?
Answer:Youspecifytheargumentsforeachobjectindividuallyinaninitializationlist.
Question:programmingiscenteredaroundobjects.
Answer:objectoriented
Question:Ifyouwerewritingthedeclarationofaclassnamed Canine ,whatwouldyou
namethefileitwasstoredin?
Answer:canine.h
ch13part1
Question:Acontractorusesablueprinttobuildasetofidenticalhouses.Areclasses
analogoustotheblueprintorthehouses?
Answer:Aclassisanalogoustotheblueprint.
Question:Whatisaconstructor?Whatisadestructor?
Answer:
Aconstructorisamemberfunctionthatisautomaticallycalledwhenaclassobjectiscreated.Adestructorisamember
functionthatisautomaticallycalledwhenaclassobjectisdestroyed.
Question:Whatareaclasssresponsibilities?
Answer:
Aclass'sresponsibilitiesarethethingsthattheclassisresponsibleforknowingandtheactionsthattheclassisresponsible
fordoing.
Question:isanobjectsabilitytocontainandmanipulateitsowndata.
Answer:encapsulation
Question:Ifyouwerewritingtheexternaldefinitionsofthe Canine classsmember
functions,youwouldsavetheminafilenamed
Answer:canine.cpp