1. What is the difference between interpreters and copi!ers"
Interpreters read thro#$h so#rce code and trans!ate a pro$ra% t#rnin$ the pro$raer&s code% or pro$ra instr#ctions% direct!' into actions. Copi!ers trans!ate so#rce code into an e(ec#tab!e pro$ra that can be r#n at a !ater tie. ). *ow do 'o# copi!e the so#rce code with 'o#r copi!er" E+er' copi!er is different. ,e s#re to chec- the doc#entation that cae with 'o#r copi!er. .. What does the !in-er do" The !in-er&s /ob is to tie to$ether 'o#r copi!ed code with the !ibraries s#pp!ied b' 'o#r copi!er +endor and other so#rces. The !in-er !ets 'o# b#i!d 'o#r pro$ra in pieces and then !in- to$ether the pieces into one bi$ pro$ra. 0. What are the steps in the de+e!opent c'c!e" Edit so#rce code% copi!e% !in-% test% repeat. 1. What is the difference between the copi!er and the preprocessor" Each tie 'o# r#n 'o#r copi!er% the preprocessor r#ns first. It reads thro#$h 'o#r so#rce code and inc!#des the fi!es 'o#&+e as-ed for% and perfors other ho#se-eepin$ chores. The preprocessor is disc#ssed in detai! on 2a' 13% 4Ob/ect5 Oriented Ana!'sis and 2esi$n.4 6. Wh' is the f#nction ain78 specia!" ain78 is ca!!ed a#toatica!!'% each tie 'o#r pro$ra is e(ec#ted. 9. What are the two t'pes of coents% and how do the' differ" C++5st'!e coents are two s!ashes 7::8% and the' coent o#t an' te(t #nti! the end of the !ine. C5st'!e coents coe in pairs 7:; ;:8% and e+er'thin$ between theatchin$ pairs is coented o#t. <o# #st be caref#! to ens#re 'o# ha+e atchedpairs.
3. Can coents be nested" <es% C++5st'!e coents can be nested within C5st'!e coents. <o# can% in fact%nest C5st'!e coents within C++5st'!e coents% as !on$ as 'o# reeber thatthe C++5 st'!e coents end at the end of the !ine. =. Can coents be !on$er than one !ine" C5st'!e coents can. If 'o# want to e(tend C++5st'!e coents to a second !ine% 'o# #st p#t another set of do#b!e s!ashes 7::8. 1>. What are the differences between the f#nction protot'pe and the f#nction definition" The f#nction protot'pe dec!ares the f#nction? the definition defines it. The protot'pe ends with a seico!on? the definition need not. The dec!aration can inc!#de the -e'word in!ine and defa#!t +a!#es for the paraeters? the definition cannot. The dec!aration need not inc!#de naes for the paraeters? the definition #st. 11. 2o the naes of paraeters ha+e to a$ree in the protot'pe% definition% and ca!! to the f#nction" No. A!! paraeters are identified b' position% not nae. 1). If a f#nction doesn&t ret#rn a +a!#e% how do 'o# dec!are the f#nction" 2ec!are the f#nction to ret#rn +oid. 1.. If 'o# don&t dec!are a ret#rn +a!#e% what t'pe of ret#rn +a!#e is ass#ed" An' f#nction that does not e(p!icit!' dec!are a ret#rn t'pe ret#rns int. 10. What is a !oca! +ariab!e" A !oca! +ariab!e is a +ariab!e passed into or dec!ared within a b!oc-% t'pica!!' a f#nction. It is +isib!e on!' within the b!oc-. 11. What is scope" Scope refers to the +isibi!it' and !ifetie of !oca! and $!oba! +ariab!es. Scope is #s#a!!' estab!ished b' a set of braces. 16. What is rec#rsion" @ec#rsion $enera!!' refers to the abi!it' of a f#nction to ca!! itse!f.
19. When sho#!d 'o# #se $!oba! +ariab!es" A!oba! +ariab!es are t'pica!!' #sed when an' f#nctions need access to the sae data. A!oba! +ariab!es are +er' rare in C++? once 'o# -now how to create static c!ass +ariab!es% 'o# wi!! a!ost ne+er create $!oba! +ariab!es. 13.What is f#nction o+er!oadin$" B#nction o+er!oadin$ is the abi!it' to write ore than one f#nction with the sae nae% distin$#ished b' the n#ber or t'pe of the paraeters. 1=. What is po!'orphis" Co!'orphis is the abi!it' to treat an' ob/ects of differin$ b#t re!ated t'pes witho#t re$ard to their differences. In C++% po!'orphis is accop!ished b' #sin$ c!ass deri+ation and +irt#a! f#nctions. )>. Is the dec!aration of a c!ass its interface or its ip!eentation" The dec!aration of a c!ass is its interface? it te!!s c!ients of the c!ass how to interact with the c!ass. The ip!eentation of the c!ass is the set of eber f#nctions stored55#s#a!!' in a re!ated CCC fi!e. )1. What is the difference between p#b!ic and pri+ate data ebers" C#b!ic data ebers can be accessed b' c!ients of the c!ass. Cri+ate data ebers can be accessed on!' b' eber f#nctions of the c!ass. )). Can eber f#nctions be pri+ate" <es. ,oth eber f#nctions and eber data can be pri+ate. ).. Can eber data be p#b!ic" A!tho#$h eber data can be p#b!ic% it is $ood pro$rain$ practice to a-e it pri+ate and to pro+ide p#b!ic accessor f#nctions to the data. )0. 2o c!ass dec!arations end with a seico!on" 2o c!ass ethod definitions" 2ec!arations end with a seico!on after the c!osin$ brace? f#nction definitions do not. )1. What is the difference between the indirection operator and the address of operator" The indirection operator ret#rns the +a!#e at the address stored in a pointer. The
address of operator 7D8 ret#rns the eor' address of the +ariab!e. )6. What is the difference between a reference and a pointer" A reference is an a!ias% and a pointer is a +ariab!e that ho!ds an address. @eferences cannot be n#!! and cannot be assi$ned to. )9. When #st 'o# #se a pointer rather than a reference" When 'o# a' need to reassi$n what is pointed to% or when the pointer a' be n#!!. )3. What does new ret#rn if there is ins#fficient eor' to a-e 'o#r new ob/ect" A n#!! pointer 7>8. )=. What is a constant reference" This is a shorthand wa' of sa'in$ 4a reference to a constant ob/ect.4 .>. What is the difference between passin$ b' reference and passin$ a reference" Cassin$ b' reference eans not a-in$ a !oca! cop'. It can be accop!ished b' passin$ a reference or b' passin$ a pointer. .1. When 'o# o+er!oad eber f#nctions% in what wa's #st the' differ" O+er!oaded eber f#nctions are f#nctions in a c!ass that share a nae b#t differ in the n#ber or t'pe of their paraeters. .). What is the difference between a dec!aration and a definition" A definition sets aside eor'% b#t a dec!aration does not. A!ost a!! dec!arations are definitions? the a/or e(ceptions are c!ass dec!arations% f#nction protot'pes% and t'pedef stateents. ... When is the cop' constr#ctor ca!!ed" Whene+er a teporar' cop' of an ob/ect is created. This happens e+er' tie an
ob/ect is passed b' +a!#e. .0. When is the destr#ctor ca!!ed" The destr#ctor is ca!!ed each tie an ob/ect is destro'ed% either beca#se it $oes o#t of scope or beca#se 'o# ca!! de!ete on a pointer pointin$ to it. .1. *ow does the cop' constr#ctor differ fro the assi$nent operator 7E8" The assi$nent operator acts on an e(istin$ ob/ect? the cop' constr#ctor creates a new one. .6. What is the this pointer" The this pointer is a hidden paraeter in e+er' eber f#nction that points to the ob/ect itse!f. .9. *ow do 'o# differentiate between o+er!oadin$ the prefi( and postfi( increents" The prefi( operator ta-es no paraeters. The postfi( operator ta-es a sin$!e int paraeter% which is #sed as a si$na! to the copi!er that this is the postfi( +ariant. .3. Can 'o# o+er!oad the operator+ for short inte$ers" No% 'o# cannot o+er!oad an' operator for b#i!t5in t'pes. .=. Is it !e$a! in C++ to o+er!oad operator++ so that it decreents a +a!#e in 'o#r c!ass" It is !e$a!% b#t it is a bad idea. Operators sho#!d be o+er!oaded in a wa' that is !i-e!' to be readi!' #nderstood b' an'one readin$ 'o#r code. 0>. What ret#rn +a!#e #st con+ersion operators ha+e in their dec!aration" None. Fi-e constr#ctors and destr#ctors% the' ha+e no ret#rn +a!#es. 01. What is a +5tab!e" A +5tab!e% or +irt#a! f#nction tab!e% is a coon wa' for copi!ers to ana$e +irt#a! f#nctions in C++. The tab!e -eeps a !ist of the addresses of a!! the +irt#a! f#nctions and% dependin$ on the r#ntie t'pe of the ob/ect pointed to% in+o-es the ri$ht f#nction.
0). What is a +irt#a! destr#ctor" A destr#ctor of an' c!ass can be dec!ared to be +irt#a!. When the pointer is de!eted% the r#ntie t'pe of the ob/ect wi!! be assessed and the correct deri+ed destr#ctor in+o-ed. 0.. *ow do 'o# show the dec!aration of a +irt#a! constr#ctor" There are no +irt#a! constr#ctors. 00. *ow can 'o# create a +irt#a! cop' constr#ctor" ,' creatin$ a +irt#a! ethod in 'o#r c!ass% which itse!f ca!!s the cop' constr#ctor. 01. *ow do 'o# in+o-e a base eber f#nction fro a deri+ed c!ass in which 'o#&+e o+erridden that f#nction" ,aseGGB#nctionNae78? 06. *ow do 'o# in+o-e a base eber f#nction fro a deri+ed c!ass in which 'o# ha+e not o+erridden that f#nction" B#nctionNae78? 09. If a base c!ass dec!ares a f#nction to be +irt#a!% and a deri+ed c!ass does not #se the ter +irt#a! when o+erridin$ that c!ass% is it sti!! +irt#a! when inherited b' a third5$eneration c!ass" <es% the +irt#a!it' is inherited and cannot be t#rned off. 03. What is the protected -e'word #sed for" protected ebers are accessib!e to the eber f#nctions of deri+ed ob/ects. 0=. What is a down cast" A down cast 7a!so ca!!ed 4castin$ down48 is a dec!aration that a pointer to a base c!ass is to be treated as a pointer to a deri+ed c!ass. 1>. What is the +5ptr" The +5ptr% or +irt#a!5f#nction pointer% is an ip!eentation detai! of +irt#a! f#nctions.
Each ob/ect in a c!ass with +irt#a! f#nctions has a +5ptr% which points to the +irt#a! f#nction tab!e for that c!ass. 11. If a ro#nd rectan$!e has strai$ht ed$es and ro#nded corners% 'o#r @o#nd@ectc!ass inherits both fro @ectan$!e and fro Circ!e% and the' in t#rn both inheritfro Shape% how an' Shapes are created when 'o# create a @o#nd@ect" If neither c!ass inherits #sin$ the -e'word +irt#a!% two Shapes are createdG one for@ectan$!e and one for Shape. If the -e'word +irt#a! is #sed for both c!asses% on!'one shared Shape is created. 1). If *orse and ,ird inherit +irt#a! p#b!ic fro Ania!% do their constr#ctors initia!iHe the Ania! constr#ctor" If Ce$as#s inherits fro both *orse and ,ird% how does it initia!iHe Ania!&s constr#ctor" ,oth *orse and ,ird initia!iHe their base c!ass% Ania!% in their constr#ctors. Ce$as#s does as we!!% and when a Ce$as#s is created% the *orse and ,ird initia!iHations of Ania! are i$nored. 1.. 2ec!are a c!ass Vehic!e and a-e it an abstract data t'pe. c!ass Vehic!e I+irt#a! +oid Jo+e78 E >? K10. If a base c!ass is an A2T% and it has three p#re +irt#a! f#nctions% how an' of these f#nctions #st be o+erridden in its deri+ed c!asses" None #st be o+erridden #n!ess 'o# want to a-e the c!ass non5abstract% in which case a!! three #st be o+erridden. 11. Can static eber +ariab!es be pri+ate" <es. The' are eber +ariab!es% and their access can be contro!!ed !i-e an' other. If the' are pri+ate% the' can be accessed on!' b' #sin$ eber f#nctions or% ore coon!'% static eber f#nctions. 16. Show the dec!aration for a static eber +ariab!e. static int itsStatic? 19. Show the dec!aration for a static f#nction pointer. static int SoeB#nction78? 13. Show the dec!aration for a pointer to f#nction ret#rnin$ !on$ and ta-in$ an
inte$er paraeter. !on$ 7; f#nction87int8? 1=. *ow do 'o# estab!ish an is5a re!ationship" With p#b!ic inheritance. 6>. *ow do 'o# estab!ish a has5a re!ationship" With containent? that is% one c!ass has a eber that is an ob/ect of another t'pe. 61. What is the difference between containent and de!e$ation" Containent describes the idea of one c!ass ha+in$ a data eber that is an ob/ect of another t'pe. 2e!e$ation e(presses the idea that one c!ass #ses another c!ass to accop!ish a tas- or $oa!. 2e!e$ation is #s#a!!' accop!ished b' containent. 6). What is the difference between de!e$ation and ip!eented5in5ters5of" 2e!e$ation e(presses the idea that one c!ass #ses another c!ass to accop!ish a tas- or $oa!. Ip!eented5in5ters5of e(presses the idea of inheritin$ ip!eentation fro another c!ass. 6.. What is a friend f#nction" A friend f#nction is a f#nction dec!ared to ha+e access to the protected and pri+ate ebers of 'o#r c!ass. 60. What is a friend c!ass" A friend c!ass is a c!ass dec!ared so that a!! its eber f#nctions are friend f#nctions of 'o#r c!ass. 61. If 2o$ is a friend of ,o'% is ,o' a friend of 2o$" No% friendship is not co#tati+e. 66. If 2o$ is a friend of ,o'% and Terrier deri+es fro 2o$% is Terrier a friend of ,o'" No% friendship is not inherited. 69. If 2o$ is a friend of ,o' and ,o' is a friend of *o#se% is 2o$ a friend of *o#se"
No% friendship is not associati+e. 63. Where #st the dec!aration of a friend f#nction appear" An'where within the c!ass dec!aration. It a-es no difference whether 'o# p#t the dec!aration within the p#b!icG% protectedG% or pri+ateG access areas. 6=. What is the insertion operator and what does it do" The insertion operator 7LL8 is a eber operator of the ostrea ob/ect and is #sedfor writin$ to the o#tp#t de+ice. 9>. What is the e(traction operator and what doesit do" The e(traction operator 7MM8 is a eber operator of the istrea ob/ect andis #sed for writin$ to 'o#r pro$ra&s +ariab!es. 91. What are the three fors of cin.$et78 and what are their differences" The first for of $et78 is witho#t paraeters. This ret#rns the +a!#e of the character fo#nd% and wi!! ret#rn EOB 7end of fi!e8 if the end of the fi!e is reached. The second for of cin.$et78 ta-es a character reference as its paraeter? that character is fi!!ed with the ne(t character in the inp#t strea. The ret#rn +a!#e is an iostrea ob/ect. The third for of cin.$et78 ta-es an arra'% a a(i# n#ber of characters to $et%and a terinatin$ character. This for of $et78 fi!!s the arra' with #p to one fewercharacters than the a(i# 7appendin$ n#!!8 #n!ess it reads the terinatin$character% in which case it iediate!' writes a n#!! and !ea+es the terinatin$character in the b#ffer. 9). What is the difference between cin.read78 and cin.$et!ine78" cin.read78 is #sed for readin$ binar' data str#ct#res. $et!ine78 is #sed to read fro the istrea&s b#ffer. 9.. What is the defa#!t width for o#p#ttin$ a !on$ inte$er #sin$ the insertion operator" Wide eno#$h to disp!a' the entire n#ber. 90. What is the ret#rn +a!#e of the insertion operator" A reference to an istrea ob/ect. 91. What paraeter does the constr#ctor to an ofstrea ob/ect ta-e" The fi!enae to be opened. 96. What does the iosGGate ar$#ent do" iosGGate p!aces 'o# at the end of the fi!e% b#t 'o# can write data an'where in the fi!e. 99. What is an inc!#sion $#ard" Inc!#sion $#ards are #sed to protect a header fi!e fro bein$ inc!#ded into a pro$ra ore than once. 93. *ow do 'o# instr#ct 'o#r copi!er to print the contents of the interediate fi!e showin$ the effects of the preprocessor" This N#iH N#estion #st be answered b' 'o#% dependin$ on the copi!er 'o# are #sin$. 9=. What is the difference between Odefine deb#$ > and O#ndef deb#$" Odefine deb#$ > defines the ter deb#$ to eN#a! > 7Hero8. E+er'where the word deb#$ is fo#nd% the character > wi!! be s#bstit#ted. O#ndef deb#$ reo+es an' definition of deb#$? when the word deb#$ is fo#nd in the fi!e% it wi!! be !eft #nchan$ed. 3>. Nae fo#r predefined acros. PP2ATEPP% PPTIJEPP% PPBIFEPP% PPFINEPP 31. Wh' can&t 'o# ca!! in+ariants78 as the first !ine of 'o#r constr#ctor" The /ob of 'o#r constr#ctor is to create the ob/ect. The c!ass in+ariants cannot and sho#!d not e(ist before the ob/ect is f#!!' created% so an' eanin$f#! #se of in+ariants78 wi!! ret#rn fa!se #nti! the constr#ctor is finished. 3). What is the difference between ob/ect5oriented pro$rain$ and proced#ra! pro$rain$" Croced#ra! pro$rain$ foc#ses on f#nctions separate fro data. Ob/ectorientedpro$rain$ ties data and f#nctiona!it' to$ether into ob/ects% and foc#ses on theinteraction aon$ the ob/ects. 3.. To what does 4e+ent5dri+en4 refer" E+ent5dri+en pro$ras are distin$#ished b' the fact that action is ta-en on!' in response to soe for of 7#s#a!!' e(terna!8 si#!ation% s#ch as a #ser&s -e'board or o#se inp#t. 30. What are the sta$es in the de+e!opent c'c!e" T'pica!!'% the de+e!opent c'c!e inc!#des ana!'sis% desi$n% codin$% testin$% pro$rain$% and interaction and feedbac- aon$ these sta$es. 31. What is a rooted hierarch'" A rooted hierarch' is one in which a!! the c!asses in the pro$ra deri+e direct!' or indirect!' fro a sin$!e base c!ass 36. What is a dri+er pro$ra" A dri+er pro$ra is sip!' a f#nction that is desi$ned to e(ercise whate+er ob/ects and f#nctions 'o# are c#rrent!' pro$rain$. 39. What is encaps#!ation" Encaps#!ation refers to the 7desirab!e8 trait of brin$in$ to$ether in one c!ass a!! the data and f#nctiona!it' of one discrete entit'. 33. What is the difference between a tep!ate and a acro" Tep!ates are b#i!t into the C++ !an$#a$e and are t'pe5safe. Jacros are ip!eented b' the preprocessor and are not t'pe5safe. 3=. What is the difference between the paraeter to a tep!ate and the paraeter to a f#nction" The paraeter to the tep!ate creates an instance of the tep!ate for each t'pe. If 'o# create si( tep!ate instances% si( different c!asses or f#nctions are created. The paraeters to the f#nction chan$e the beha+ior or data of the f#nction% b#t on!' one f#nction is created. =>. What is the difference between a t'pe5specific tep!ate friend c!ass and a $enera! tep!ate friend c!ass" The $enera! tep!ate friend f#nction creates one f#nction for e+er' t'pe of the paraeteriHed c!ass? the t'pe5specific f#nction creates a t'pe5specific instance for each instance of the paraeteriHed c!ass. =1. Is it possib!e to pro+ide specia! beha+ior for one instance of a tep!ate b#t not for other instances" <es% create a specia!iHed f#nction for the partic#!ar instance. In addition to creatin$Arra'GGSoeB#nction78% a!so create Arra'GGSoeB#nction78 to chan$e the beha+iorfor inte$er arra's. =). *ow an' static +ariab!es are created if 'o# p#t one static eber into a tep!ate c!ass definition" One for each instance of the c!ass. =.. What is an e(ception" An e(ception is an ob/ect that is created as a res#!t of in+o-in$ the -e'word throw. It is #sed to si$na! an e(ceptiona! condition% and is passed #p the ca!! stac- to the first catch stateent that hand!es its t'pe. =0. What is a tr' b!oc-" A tr' b!oc- is a set of stateents that i$ht $enerate an e(ception. =1. What is a catch stateent" A catch stateent has a si$nat#re of the t'pe of e(ception it hand!es. It fo!!ows a tr' b!oc- and acts as the recei+er of e(ceptions raised within the tr' b!oc-. =6. What inforation can an e(ception contain" An e(ception is an ob/ect and can contain an' inforation that can be defined within a #ser5created c!ass. =9. When are e(ception ob/ects created" E(ception ob/ects are created when 'o# in+o-e the -e'word throw. =3. Sho#!d 'o# pass e(ceptions b' +a!#e or b' reference" In $enera!% e(ceptions sho#!d be passed b' reference. If 'o# don&t intend to odif' the contents of the e(ception ob/ect% 'o# sho#!d pass a const reference. ==. Wi!! a catch stateent catch a deri+ed e(ception if it is !oo-in$ for the base c!ass" <es% if 'o# pass the e(ception b' reference. 1>>. If there are two catch stateents% one for base and one for deri+ed% which sho#!d coe first" catch stateents are e(ained in the order the' appear in the so#rce code. The first catch stateent whose si$nat#re atches the e(ception is #sed. 1>1. What does catch7...8 ean" catch7...8 wi!! catch an' e(ception of an' t'pe. 1>). What is a brea-point" A brea-point is a p!ace in the code where the deb#$$er wi!! stop e(ec#tion. 1>. What is the difference between strcp'78 and strncp'78" strcp'7char; destination% char; so#rce8 copies so#rce to destination% and p#ts a n#!! at the end of destination. destination #st be !ar$e eno#$h to accoodate so#rce% or strcp'78 wi!! sip!' write past the end of the arra'. strncp'7char; destination char; so#rce% int howan'8 wi!! write howan' b'tes of so#rce to destination% b#t wi!! not p#t a terinatin$ n#!!. 1>0. What does ctie78 do" ctie78 ta-es a tiePt +ariab!e and ret#rns an ASCII strin$ with the c#rrent tie. The tiePt +ariab!e is t'pica!!' fi!!ed b' passin$ its address to tie78. 1>1. What is the f#nction to ca!! to t#rn an ASCII strin$ into a !on$" ato!78 SOJE JO@E VIVA QUESTIONS 1.What are c!asses" A c!ass is a co!!ection of ob/ects of sii!ar t'pe. Once a c!ass is defined an' Q n#ber of ob/ects can be created of that c!ass. E(ap!es of c!asses are c!ass of cars% c!ass of pens% c!ass of birds etc. Q What are Instances" Instances are essentia!!' ob Q /ects deri+ed o#t of c!asses. When an ob/ect is created for a partic#!ar c!ass the process is ca!!ed Instantiation. Q In $enera!% !ife tie of ob/ect is nothin$ b#t the tie between an ob/ect creation% ti!! the ob/ect is no !on$er #sed and is destr#cted or freed. ).What is ob/ect orientation" It is a techniN#e for s'ste ode!in$. It offers a n#ber of concepts ..Cointer t'peG A Cointer is a +ariab!e which ho!ds the address of another +ariab!e. 0.Const Q#a!ifierG Const N#a!ifier is #sed to pre+ent fro accidenta! chan$es within a pro$ra. 1.2ifferences between Str#ct#red Cro$rain$ and OOC Q In St.C ephasis is on What is happenin$. In OOC ephasis is on Who is bein$ affected. Q 2ata o+e open!' aro#nd the s'ste. In St.C. In OOC the data and f#nctions that operate on the data are tied to$ether Q In St.C ost fns share $!oba! data. In OOC data is hidden and cannot be accessed b' e(terna! f#nctions. Q In St.C% Far$e pro$ras are di+ided to sa!!er pro$ras -nown as f#nctions% In OOC the' are di+ided into ob/ects. 6.En#erated 2ata t'peG It is a #ser5defined data t'pe. R The s'nta( of en# stateent is sii!ar to that of str#ct R Bor E(G en# shapeI circ!e% sN#are% trian$!eK? 9. New and 2e!ete G 7Jeor' Jana$eent Operators8 These are the #nar' operators to perfor d'naic eor' a!!ocation and dea!!ocation New operator is #sed to create ob/ects. The Aenera! Bor isG Cointer5+ariab!e E new data5t'pe? The $enera! for of #sin$ de!ete de!ete pointer5+ariab!e? Bor E(G de!ete p? To free d'naica!!' a!!ocated arra' de!ete SsiHeT pointer5+ariab!e Bor E(G de!ete S1>T p? Bor E(G int ;p E new int? 3. In!ine B#nctionsGAn in!ine f#nction is a f#nction that is e(panded in !ine when it is in+o-ed In!ine f#nction5header If#nction bod' KE(G in!ine int sN#are7int a8 Iret#rn a;a K? =. Aeneric B#nctions A $eneric f#nction defines a $enera! set of operations that can be app!ied to +ario#s t'pes of data.. A $eneric f#nction is created #sin$ the -e'word tep!ate. The $enera! for of tep!ate f#nction definition is 1. Tep!ate ret5t'pe f#nc5nae7paraeter !ist8 I ::f#nction bod' K 1>. Constr#ctors and 2estr#ctors 1. C++ a!!ows a#toatic initia!iHation of ob/ects when the' are created. This is perfored thro#$h the #se of a constr#ctor f#nction. ). Constr#ctor is a specia! f#nction that is a eber of the c!ass and has the sae nae as that c!ass. .. The Constr#ctor is a#toatica!!' ca!!ed whene+er an ob/ect of its associated c!ass is created. 0. A Constr#ctor is dec!ared and defined as fo!!ows 2estr#ctorsG 1. A destr#ctor as the nae ip!ies is a cop!eent of the constr#ctor% #sed to destro' ob/ects. ). It wi!! be in+o-ed ip!icit!' b' the copi!er #pon e(it fro pro$ra or f#nction or b!oc- .. Foca! ob/ects are destro'ed when the b!oc- is !eft. A!oba! ob/ects are destro'ed when the pro$ra terinates. 0. It is a eber f#nction whose nae is sae as the c!ass nae b#t is preceded b' a ti!de 7U8 operator. E( G Ustac-78? 1. There are an' reasons wh' a destr#ctor a' be needed. E(G An ob/ect a' need to dea!!ocate eor' that it had pre+io#s!' a!!ocated% or c!ose a fi!e that it had opened. 6. A destr#ctor ne+er ta-es an' ar$#ent nor does it ret#rn an' +a!#e 9. It is a $ood practice to dec!are destr#ctors 11. C!ass is s'ntactica!!' sii!ar to a str#ct. The on!' difference between the is that b' defa#!t a!! ebers are p#b!ic in a str#ct and pri+ate in a c!ass. 1). Briend B#nctions 1. Cri+ate ebers cannot be accessed fro o#tside the c!ass i.e b' a non5eber f#nction ). C++ a!!ows a non5eber f#nction to access pri+ate ebers of a c!ass b' #sin$ a friend f#nction. .. A friend f#nction need not be a eber of an' c!ass. 0. To a-e an o#tside f#nction friend!' to a c!ass% inc!#de its protot'pe within the c!ass% precedin$ it with the -e'word friend. 1.. Static 2ata Jebers7S2J8 1. Crecedin$ a data eberVs dec!aration with the -e'word static te!!s the copi!er that on!' one cop' of that +ariab!e wi!! e(ist and that a!! ob/ects of the c!ass wi!! share that +ariab!e. ). A static data eber is initia!iHed to Hero when the first ob/ect of its c!ass is created. No other initia!iHation is peritted. .. 2ec!arin$ a static data eber is not definin$ it 7eans not a!!ocatin$ stora$e for it8. @eeber c!ass is a !o$ica! constr#ct that does not ha+e ph'sica! rea!it'. 0. 2efinin$ a static data eber is done o#tside the c!ass b' redec!arin$ the static +ariab!e #sin$ the scope reso!#tion operator . 1. S2J are nora!!' #sed to aintain +a!#es coon to entire c!ass Static Jeber B#nctions7SJB8 There are se+era! restrictions p!aced on Static eber f#nctions. 1. A static f#nction can ha+e access to on!' other static ebers dec!ared in the sae c!ass. ). A!oba! f#nctions and data a' be accessed b' SJB. .. A SJB does not ha+e a this pointer. 0. There cannot be a static +ersion and non5static +ersion of the sae f#nction 1. A SJB a' not be +irt#a!. 6. The' cannot be dec!ared as const or +o!ati!e 9. A static eber f#nction can be ca!!ed #sin$ the c!ass nae as fo!!ows C!assnae GG f#nction5nae? 3. Use is to preinitia!iHe pri+ate static data before an' ob/ect is created 10. This Cointer When a eber f#nction is ca!!ed% it is a#toatica!!' passed an ip!icit ar$#ent that is a pointer to the in+o-in$ ob/ect. This pointer is ca!!ed this 11.Operator O+er!oadin$ The echanis of $i+in$ additiona! eanin$ to an operator is -nown as operator o+er!oadin$. 16.IN*E@ITANCE 1. The echanis of deri+in$ a new c!ass fro an o!d one is ca!!ed Inheritance. ). The concept of Inheritance pro+ides the idea of re#sabi!it'. This is basica!!' done b' creatin$ new c!asses% re#sin$ the properties of the e(istin$ ones. .. A c!ass that is inherited is referred to as base c!ass% and a c!ass that inherits is ca!!ed the deri+ed c!ass. 0. 2ifferent t'pes of InheritanceG 19.Crotected Jebers When a eber of a c!ass is dec!ared as protected% that eber is not accessib!e b' other noneber e!eents of the pro$ra 13.A Virt#a! f#nctionG is a eber f#nction that is dec!ared within a base c!ass and redefined b' a deri+ed c!ass.To create a +irt#a! f#nction% precede the f#nctionVs dec!aration in the base c!ass with the -e'word Virt#a!. 1=.. I:O OperationsG C++ #ses the concept of strea and strea c!asses to ip!eent the I:O Operations. A strea acts as an interface between the pro$ra and I:O de+ice. )>.What is Co!'orphis" It is $enera!!' abi!it' to appear in an' fors. In OOC% po!'orphis refers to a pro$rain$ !an$#a$eVs abi!it' to process ob/ects different!' dependin$ on their data t'pe or c!ass. )1.What is Abstraction" The process of pic-in$ o#t 7abstractin$8 coon feat#res of ob/ects and proced#res. A pro$raer wo#!d #se abstraction. Abstraction is one of the ost iportant techniN#es in software en$ineerin$ and it is c!ose!' re!ated to two other techniN#es5 encaps#!ation and inforation hidin$. A!! these three techniN#es are #sed to red#ce cop!e(it'.