Sie sind auf Seite 1von 16

C++ QUESTION

Chapter: 1 1. What do u mean by programming methodology? Ans: it is a method by which we are dividing the programs. 2. What are the types of programming methodology? Ans: it is mainly of 2 types: a) object oriented programming ( OOPs) b) proced re oriented programming ( POPs) !. What is the difference between oop & pop? Ans: "ifference is given below: a) #n oop$ program is divided into objects. % t in pop$ program is divided into f nction. b) Oop follows bottom& p approach. % t Pop follows top&down approach. c) #n oop$ data may be declared as private$ p blic or protected. % t in pop$ datas are always declared as global. d) #n oop$ data hiding concept is fo nd. 'o data is sec red. % t in pop$ data hiding concept is not fo nd. 'o data is not sec red. e) () of oops are c**$ java$ 'malltal+$ (iffel$ charm**. % t e) of pop are c$ fortan$ ,O%O-$ basic. .. What are the basic oops concept? Ans: %asic oops concepts are class$ object$ data abstraction$ encaps lation$ inheritance$ polymorphism$ message passing /. What is the access specifier available in c++? Ans: 0here are ! types of access specifier is present. 0hese are private$ p blic 1 protected. 2. What do u mean by data hiding concept? Ans: if we declare the data as private$ it can only access by the f nction of that class only. Other f nctions can not access the data. #t is called data hiding. 3. What do u mean by message passing? Ans: d e to message passing$ the objects can comm nicate with each other. 4. Define object in terms of class? Ans: object is a variable of class type. 5. Write some oops language? Ans: c**$ java$ 'malltal+$ (iffel. 16. What is the advantage of oop? Ans: advantage is given below: a) 7sing inheritance$ red ndancy can be avoided. b) 'oftware comple)ity can be easily managed. c) " e to data hiding concept$ data is m ch sec red. Chapter: 2 11. Who developed c++? Ans: %jarne 'tro sstr p developed c** at A0 1 0 %ell lab in the year 1546. 12. What is the reason behind the development of c++? Ans: 0o avoid the problem i.e occ rred in c$ a new lang age is developed called c**. 0he problems are:

a) "atas are declared as global. 'o data is not sec red. b) #n c$ program is divided into f nction. 'o every f nction can access the data. #f program is large$ then it is very diffic lt to +now which f nction can access which data. 1!. What is the use of #include<iostream>? Ans: it is a preprocessor directive that instr cts the compiler to add the file into so rce code. #ostream means inp t$ o tp t stream. #np t stream ta+es the inp t from +eyboard. O tp t stream shows the o tp t. 1.. What is the use of main ! in a program? Ans: it is the main part in the program where the e)ec tion begins. 1/. What is the difference between input stream & output stream? Ans: #np t stream ta+es the inp t from +eyboard. O tp t stream shows the o tp t. 12. "ow to create# compile & run the file in $inu% environment? Ans: a) ,reate : vi file name.cpp b) ,ompile: c** file name. cpp c) 8 n: . 9 a. o t 13. What is the use of namespace &'D in ++ program? Ans: it is a scope for identifier. '0" is a namespace that contains all the class libraries. Chapter: 3 14. What do u mean by to(en? Ans: 0o+en is the smallest individ al nit in a program. 15. What are the types of to(en available in c++? Ans: ,** contains these to+ens: +eyword$ identifiers$ constant$ string$ operator. 26. "ow many (eywords are used in c++? Ans: :eywords are reserved set of words with fi)ed meaning. 0here are 2! +eywords in c**. :eywords are: a to$ brea+$ case$ char$ defa lt$ do$ en m$ for$ friend etc. 21. What are the types of data type? Ans: "ata type is mainly divided into ! types: ser defined$ f ndamental$ and derived. a) 7ser defined data type incl des: class$ str ct re$ nion$ en m. b) "erived data type incl des: array$ f nction$ pointer$ reference. c) ; ndamental data type incl des: int$ float$ do ble$ char 22. What is the use of void data type? Ans: <oid data type is sed for following p rpose. a) #t acts as a generic pointer. b) #t specifies the ret rn type. c) #t is also sed as a arg ment for the f nction. 2!. What is the difference between array & structure? Ans: Array is a collection of similar data type where as str ct re is a collection of dissimilar data type. Array is a derived data type where str ct re is a ser defined data type. 2.. What is the difference between structure in c & c++? Ans: 'tr ct re in c contains only data members. % t str ct re in c** contains data member 1 f nctions. 2/. What is the difference between structure & class in c++?

Ans: #n , str ct re data members are by defa lt p blic. % t in ,** str ct re data members are by defa lt private. , str ct re does not s pport the oops concept. % t c* * str ct re s pports the oops concept.

22. What is the difference between structure & union? Ans: #n str ct re$ the entire member has its own memory location. % t in nion all the members share the memory location. 23. What is the use of reference data type? Ans: it provides an alternative name for previo sly defined variable. 'ynta): int a =16> #nt 1b=a> 24. What do u mean by anonymous union? Ans: 0he nion that does not contain any tag name. (): nion ? #nt a> ;loat j> @ 25. What are the built in data type available in c++? Ans: #nt$ char$ do ble$ float. !6. What is the use of scope resolution operator? Ans: it is mainly sed to access the global variable. !1. What are the memory management operators available in c++? Ans: Aew 1 "elete operator. !2. What is the use of new & delete operator? Ans: Aew operator is sed to allocate the memory. "elete is sed to deallocate the memory. !!. What is the difference between new & malloc? Ans: "ifference is given below: a) Aew is a operator i.e. sed in c**. % t malloc is a f nction sed in c. b) Aew creates the object 1 also allocate the memory. % t malloc f nction only allocates the memory. c) Aew can be overloaded. % t malloc can not be overloaded. !.. What is the use of insertion & e%traction operator? Ans: #nsertion operator displays the o tp t on the screen. ()traction operator e)tracts the val e from the +eyboard. Chapter: 4, !/. What do u mean by class? Ans: class is a collection of data 1 member f nction. !2. What is the synta% of class? Ans: class Bclass name C ? "ata member declaration> Dember f nction declaration> @ !3. "ow to define the member function in a class? Ans: 0he f nction that is enclosed in a class is called is called member f nction. !4. What is the difference between function & member function? Ans: ; nction is a bloc+ of statements that perform some tas+. % t the f nction that is enclosed in a class is called is called member f nction. !5. What are the steps in class program? Ans: .

a) b) c) d) e) f)

"eclare a class. "eclare the data member 1 member f nction in side the class. "efine the member f nction inside or o tside the class. "eclare the main program. ,reate the object inside the class. Access the member f nction sing the object.

.6. What is the difference between private# public & protected? Ans: Private: if we declare the data as private$ it can only access by the f nction of that class only. P blic: if we declare the data as p blic$ it can access by the f nction of all classes. Protected: if we declare the data as protected$ it can only access by the f nction of the s b class only. .1. What do u mean by static data member? Ans: #f we declare the data as static then its val e will remain constant d ring the program. .2. What are the properties of static data member? Ans: Properties is given below: a) #t can be shared by the entire object. b) %y defa lt its val e is initialiEed to Eero. c) #ts val e will remain constant. d) #t m st be initialiEed o tside the class. e) #t ses the +eyword static. .!. What do u mean by static member function? Ans: a) #t can only access the static data member. b) #t can be invo+ed sing class name instead of object name. ... What is the use of static object? Ans: 'tatic object initialiEes all the data member to Eero. ./. What is constant member function? Ans: #t can not modify any data member in the class. .2. "ow to access the private member function in a class? Ans: Fhen we declare the member f nction as private$ then it can be accessed in side the p blic member f nction. Object can not invo+e the private member f nction. .3. Why array of object is used? Ans: 0o display the o tp t of more than one object we can se the array of object concept. .4. Difference between local class & global class? Ans: "ifference between this is given below: a) 0he class i.e. declared o tside the main f nction is called global class. % t the class i.e. declared inside the main f nction is called local class. b) -ocal class has only local object. % t global class has both local 1 global object. c) -ocal class can not have static data member 1 member f nction. % t global class has static data 1 static member f nction. .5. What do u mean by empty class? Ans: 0he class witho t any data member 1 member f nction is +nown as empty class.

/6. What is the use of empty class? Ans: #t is generally sed in e)ception handling program. /1. What is const argument? Ans: Fhen we declare the data as constant$ its val e remain constant. Chapter: 5 /2. What do u mean by function? Ans: it is a bloc+ of statements that perform some tas+s /!. What is the need of function? Ans: f nction is sed for following p rpose: a) 7sing f nction$ large program can be divided into smaller ones. #t is easy to deb g 1 find o t the errors in it. b) #f we want to perform tas+ repetitively$ it is not necessary to rewrite the partic lar bloc+ of statements again 1 again. 'hift the partic lar bloc+ of statement in a ser defined f nction. /.. What is function prototype? Ans: it is a declaration statement in a program. 'ynta): ret rn type f nction name (arg ment)> (): voids add (int$ int)> //. What is the function arguments used in c++? Ans: 0here are 2 types of arg ments are sed in c**. a) Act al arg ment: arg ment of calling f nction. b) ;ormal arg ment: arg ment of called f nction. /2. "ow to pass the parameters in function? Ans: it can be possible in ! ways: a) call by val e( pass by val e) b) call by reference ( pass by reference) c) call by address( pass by address) /3. What is inline function? Ans: %y defa lt all the f nctions defined inside the class is called inline. #f we want to ma+e the f nction o tside the class as inline$ then inline +eyword is sed. /4. What is the advantage of inline function? Ans: ()ec tion is very first. /5. What is the disadvantage of inline function? Ans: #t ta+es more memory space. 26. What are the rules for inline function? Ans: #t has following r les: a) #nline f nction is sed when the program contains few statements. b) 8ec rsion f nction can not be inline. c) Dain ( ) f nction can not be wor+ as inline. d) #t sho ld not contain static variable. e) ; nction containing go to$ for$ switch can not be inline. 21. What is the difference between inline & macro? Ans: "ifference between inline 1 macro is given below: a) #n inline f nction when the f nction is called the code of the f nction is replaced with the f nction call. % t in macro only the val e is replaced. b) #n inline f nction$ error is chec+ed d ring e)ec tion. % t in macro error is not chec+ed.

22. What is the difference between open subroutine & close sub

routine?
Ans: #nline f nction is called open s b ro tine b t normal f nction is called close s b ro tine. "ifference is given below. 2!. What is the difference between inline function & function? Ans: "ifference between inline f nction 1 f nction is given below: a) #n general f nction when we call the f nction the control goes to the f nction definition 1 then it comes to the each statement in the f nction definition> finally the control comes to the main program. % t in inline f nction when the f nction is called the code of the f nction is replaced with the f nction call b) General f nction ta+es less memory space where inline f nction ta+es more memory space. c) #n f nction$ e)ec tion speed is less b t in inline f nction e)ec tion is very first. 2.. What is function overloading? Ans: f nctions having same name b t different arg ments are called f nction overloading. 2/. What is the difference between function overloading & function

overridden?
Ans: f nctions having same name b t different arg ments are called f nction overloading. % t in f nction overridden$ if the base class 1 derived class have same f nction name 1 f nction parameter$ then f nction in derived class is said to override the f nction or method in the base class. 22. What is the use of friend function? Ans: " e to data hiding concept$ non member f nctions can not access the private data. 'o to access this$ c** provides a new concept called friend f nction. #f we declare the f nction as a friend of other class$ then it can access the private data. 23. What are rules for friend function? Ans: a) 0he friend +ey word is sed. b) #n f nction declaration$ class name is given in place of arg ment. c) #n f nction definition$ object is created in place of f nction arg ment d) #t can be accessed sing the object name. 24. What is friend class? Ans: #t is possible to declare the whole class as friend. #t is +nown as friend class. 25. "ow to calculate the si)e of object? Ans: 'iEe of object is eH al to the s m of the siEe of all class data member of the class. 36. What are the library functions? Ans: in c**$ mainly . library f nctions are sed: ceil ceill$ floor$ and floorl. 31. "ow to round up & round down the float number? Ans: float n mber can be ro nd p sing ceil 1 ceill library f nction. % t float n mber can be ro nd down sing floor 1 floorl library f nction. Chapter: 6 32. What do u mean by constructor?

Ans: it is a special member f nction which is sed to initialiEe the object of a class when the object is created. #t is called constr ctor beca se it constr cts the val e of the data member. 3!. What are the properties of constructor? Ans: properties of constr ctor are given below: a) #t is sed to initialiEe the object when the object is created. b) #ts name is same as class name. c) #t has no ret rn type. d) #t sho ld be declared in p blic part. e) #t can be overloaded. f) #t can not be inherited. g) #t can not be virt al. 74. What are the types of constructor? Ans: it is mainly of / types: a) "efa lt constr ctor. b) ParameteriEed constr ctor. c) ,opy constr ctor. d) "efa lt arg ment constr ctor. e) "ynamic constr ctor. 3/. What is the use of default argument constructor? Ans: ParameteriEed constr ctor having defa lt val e is called defa lt arg ment constr ctor. 32. What is dynamic constructor? Ans: 0he constr ctor can also be sed to allocate the memory while creating the object. #t is called dynamic constr ctor. #t will enable the system to allocate the right amo nt of memory. 33. What is the difference between shallow copy & deep copy? Ans: 34. What is destructor? Ans: "estr ctor is sed to destroy the object i.e. created by constr ctor. 35. What are the properties of destructor? Ans: a) its name is same as class name. b) #t has no ret rn type. c) #t is same as class name only proceeding by a symbol tilde i.e. I. d) #t can not be overloaded. e) #t can be virt al. f) #t never ta+es any arg ment. g) #n a program only one destr ctor is present. 46. What is the difference between constructor & destructor? Ans: "ifference is given below: a) ,onstr ctor is sed to constr ct the val e of data member. % t destr ctor is sed to destroy the val e of data member i.e. created by constr ctor. b) ,onstr ctor can be overloaded b t destr ctors can not be overloaded. c) ,onstr ctor can not be virt al b t destr ctor can be. d) ,onstr ctor can be called implicitly or e)plicitly. 41. What is const object? Ans: Fe can ma+e the object constant by the +eyword JconstK. #t can only access the constant member f nction.

42. What is anonymous object? Ans: it is possible to create the object witho t the name 1 s ch objects are called anonymo s object. #t is only possible in constr ctor. 4!. What is the difference between local & global object? Ans: when the object is declared inside the main f nction it is called local object. % t the object i.e. defined o tside the main f nction is called global object. 4.. "ow to use the private constructor? Ans: when the constr ctor is declared as private$ it can be invo+ed thro gh the p blic member of the class.

Chapter: 7 4/. What is inheritance? Ans: #n inheritance a new class is created from the e)isting one. 0he e)isting class is called parent9 s per9 base class. 0he new class is called child9 s b9 derived class. 42. What do u mean by reusability? Ans: "erived class re ses the property of base class. #t is called re sability. 43. What are the types of inheritance? Ans: there are / types of inheritance: a) 'ingle inheritance. b) D ltiple inheritances. c) D ltilevel inheritance. d) Lierchical inheritance. e) Lybrid inheritance. 44. What is the difference between multiple & multilevel inheritance? Ans: #n m ltiple inheritances$ a new class is derived from more than one base class. % t in m ltilevel inheritance$ a new class is derived from a derived class i.e. derived from another base class. 45. What is the use of virtual base class? Ans: 0o overcome the ambig ity that is occ rred in m ltipath inheritance c** provides a new +eyword that is virt al. #f we declare the base class as virt al$ then the compiler ta+es necessary steps avoid the d plication of member variable. 56. What is delegation? Ans: "eclaring the object as a class data member in another class is +nown as delegation. 51. What is containership? Ans: Fhen a class has an object of another class as its data member$ the class is called container class 1 the relationship between two classes is +nown as containership. 52. What is abstract class? Ans: Fhen a class is not sed for creating an object$ it is called as abstract class. #t only acts as a base class. 5!. What is common constructor? Ans: Fe +now constr ctor can not be inherited. Fhen a class is derived from another class$ it is possible to define constr ctor in derived class. "ata member of both base 1 derived class can be initialiEed sing derived class constr ctor. 0h s the constr ctor of derived class wor+s for its base class. ' ch constr ctors are +nown as common constr ctor. 5.. What is the difference between public & private inheritance? Ans: when a class is derived p blicly$ all the p blic members of base class can be accessed directly in the derived class. % t in private inheritance$ the p blic member of base class can be accessed sing p blic f nction of derived class. 5/. What is the advantage of inheritance? Ans: a) #nheritance provides re se of code. 'o no need to write the code again 1 again. b) %y re sability$ the development time of software is red ced. 52. What is the disadvantage of inheritance?

16

Ans: #n class hierarchy$ vario s data elements remain n sed. 0he memory allocated to them is not tiliEed.

11

53. What do u mean by function overloading in inheritance? Ans: #f f nction overloading occ rs in inheritance$ then sing scope resol tion operator$ base class member f nction can be accessed Chapter: 8 98. What is operator overloading? Ans: Operator is a symbol that performs on constant 1 variable. % t it can not operate on object. 0hatMs why c** provides a new concept by which operators are providing e)tra tas+ i.e. operate on objects. #t is called operator overloading. 55. What is the advantage of operator overloading? Ans: sing operator overloading$ it can acts on the objects. 166. "ow to overload the operator? Ans: (ither sing member f nction or friend f nction. 161. "ow many arguments are used for unary & binary operator

overloading?
Ans: Unar : sing member f nction 6 arg ments 1 sing friend f nction 1 arg ment. !"nar : sing member f nction 1arg ments 1 sing friend f nction 2 arg ments. 162. Which operators can not be overloaded? Ans: scope resol tion operator (::)$ siEe of operator (siEe of ( ))$ dot operator ( .)$ pointer to member operator (. N)$ ternary operator (O :) 16!. Which operators can*t be overloaded using friend function? Ans: f nction call operator$ s bscript operator$ assignment operator$ class member access operator 16.. What is the return type of operator function? Ans: ,lass type 16/. What are the types of conversion? Ans: 0here are ! types of conversion: %asic to class type conversion. ,lass to basic type conversion. ,lass to class type conversion. 162. What is the difference between basic to class & class to basic type

+onversion?
Ans: Fhile converting from basic to class type$ the conversion f nction sho ld be defined in terms of constr ctor. % t while converting from class to basic type$ the conversion f nction sho ld be defined in terms of operator f nction. Chapter: 9 163. What do u mean by polymorphism? Ans: poly means many 1 morphism means forms. 'o polymorphism means one name having different forms. 164. What are the types of polymorphism? Ans: 2 types of polymorphism i.e. compile time 1 r n time. 165. What the difference is between compile & run time polymorphism? Ans: "ifference between compile time 1 r n time polymorphism is given below: #n compile time polymorphism an appropriate member f nction is selected d ring compile time. % t in r n time polymorphism an appropriate member f nction is selected d ring r n time.

12

,ompile time polymorphism incl des f nction overloading 1 operator overloading. 8 n time polymorphism incl des virt al f nction ,ompile time polymorphism is called early or static binding. % t r n time polymorphism is called late or dynamic binding. 116. What do u mean by virtual function? Ans: Fhen the f nction in both base 1 derived class has same name$ then the f nction in base class is said to be virt al sing virt al +eyword. 111. What is the difference between base class pointer & derived class pointer# Ans: %ase class pointer points to both base 1 derived class object. % t derived class pointer points to only the object of derived class. 112. What are the rules for virtual function? Ans: 8 les are given below: ,onstr ctor can not be virt al b t destr ctor can be virt al. <irt al f nction can be invo+ed sing object pointer. <irt al f nction may be declared as friend for another class. 11!. What is pure virtual function? Ans: <irt al f nction i.e. eH ated to Eero is called p re virt al f nction. 11.. What is abstract class? Ans: A class that contains p re virt al f nction is called abstract class. Chapter: 1$ 115. What is generic programming? Ans: 0he program that s pports generic class 1 generic f nction is called generic programming. 112. What is the difference between generic class & generic function? Ans: A class that wor+s for all data types is +nown as class template. % t a f nction that wor+s for all data type is +nown as f nction template. 113. What is template? Ans: 0emplate s pports generic programming. 114. What is the need of template? Ans: advantage of template is given below: Program siEe is decreased. -ess n mber of local variables is declared. 0ime comple)ity is less. 119. What "% the &"''eren(e )et*een '+n(t",n ,-er.,a&"n/ 0 te1p.ate# Ans: "ifference is given below: #n f nction overloading more n mber of local variables are declared b t in template less n mber of local variables are declared. #n f nction overloading program siEe is large b t in template f nction siEe will decrease. 12$. What are the t pe% ,' te1p.ate# Ans: 2 types i.e. class template 1 f nction template. 121. Wr"te the % nta2 ,' (.a%% te1p.ate 0 '+n(t",n te1p.ate# Ans: ; nction template synta): 0emplateBclass 0C

1!

8et rn type f nction name (template type arg ment) ? @ ,lass template synta): 0emplateBclass 0C ,lass class name ? @> 122. What "% the &"''eren(e )et*een (.a%% te1p.ate 0 te1p.ate (.a%%# Ans: A class that wor+s for all data type is +nown as class template. % t when a class is derived class template$ it is +nown as template class. 123. What "% the &"''eren(e )et*een '+n(t",n te1p.ate 0 te1p.ate '+n(t",n# Ans: A f nction that wor+s for all data type is +nown as f nction template. % t when a f nction is derived from f nction template is +nown as template f nction. 124. What "% the &"''eren(e )et*een te1p.ate 0 1a(r,# Ans: "ifference is given below: 0emplate is sed for all the data types. % t macro is only sed for replacement of val e. #n template error is chec+ed d ring compilation. % t in macro error is not chec+ed. Chapter: 11 125. What &, + 1ean ) err,r "n a pr,/ra1# Ans: (rror is a condition that does not allow a program to e)ec te or r n. 126. What are the t pe% ,' err,r a-a".a).e "n (++# Ans: 2 types of errors are available: compile time 1 r n time error. 127. What the &"''eren(e "% )et*een (,1p".e t"1e 0 r+n t"1e err,r# Ans: "ifference is given below: #n compile time error$ error is chec+ed d ring compilation. % t in r n time error$ error is chec+ed d ring r n time. ()ample of ,ompile time error is missing of semicolon$ missing of brac+ets$ ndeclared identifier. ()ample of r n time error is division by Eero 1 array o t of range. ,ompile time error is also +nown as synta) error. % t r n time error is +nown as logical error. 128. What "% e2(ept",n# Ans: ()ception is a r n time error. 129. What are the t pe% ,' e2(ept",n# Ans: ()ception is of two types: synchrono s 1 asynchrono s. 13$. 3,* t, han&.e the e2(ept",n "n (++# Ans: ,** only handles the synchrono s e)ception. 0o handle the e)ception$ e)ception handling mechanism is sed. #t is b ilt pon ! +eywords i.e. try$ throw 1 catch. Tr : e)ception is generated here. Thr,*: e)ception is thrown sing throw statement. Cat(h: thrown e)ception is ca ght sing catch statement. 131. 3,* t, han&.e the +n(a+/ht e2(ept",n# Ans: nca ght e)ception can be handled sing following f nctions: terminate ( )$ set terminate ( ) 1 abort ( ) f nction.

1.

Chapter: 12 132. What &, + 1ean ) '".e# Ans: ;ile is a collection of related data stored in a partic lar area on the dis+. 133. Wh '".e "% n,t %t,re& "n pr"1ar 1e1,r # Ans: Primary memory is volatile. 'o file is not stored here. 134. 3,* t, ,pen a '".e# Ans: ;ile can be opened in 2 ways: 7sing constr ctor. 7sing member f nction open ( ). 135. What (.a%%e% +%e& ',r '".e ,perat",n# Ans: if stream: read operation Of stream: write operation ;stream: both read 1 write operation. 136. What are the '".e ,pen"n/ 1,&e%# Ans: "ifferent file opening modes are given below: I,%::"n: sed for read p rpose. I,%::,+t: sed for write p rpose. I,%:: app: add at the end. I,%:: ate : modify 1 add. I,%:: tr+n(: ma+es the file to Eero length. I,%:: )"nar : opens the file in binary mode. I,%:: n, (reate : open fails if the file does not e)ist. I,%:: n, rep.a(e : open fails if the file already e)ists. 137. What are the '".e p,"nter%# Ans: 0here are two file pointers: get 1 p t pointer. 138. What are the '".e p,"nter han&."n/ '+n(t",n# Ans: see+p ( )$ see+g ( )$ tellp ( )$ tellg ( ) 139. What "% the &"''eren(e )et*een )"nar 0 te2t 1,&e "n a '".e# Ans: ' ppose we want to enter the data int a=12!$ then in binary mode it will ta+e 2 byte beca se int reH ires 2 byte. % t in te)t mode it will ta+e ! byte $ one for each digit. 14$. 3,* t, '"n& the en& ,' a '".e# Ans: 0o find the end of a file$ eof ( ) f nction is sed. 141. 3,* t, (he(4 the err,r "n a '".e# Ans: 0he logical negation operator (P) is sed to chec+ the error in a file. #t can be sed with the object of file stream class. 142. What &, + 1ean ) (,11an& ."ne ar/+1ent# Ans: Fhen some arg ment is associated with command$ these are called command line arg ment. #t is sed with f nction main ( ). 'ynta): Dain (int argc$ char argv Q R) 143. 3,* t, han&.e the err,r &+r"n/ '".e ,perat",n# Ans: sing error handling f nctions 1 these are eof ( )$ bad ( )$ good ( )$ fail ( ). Chapter: 13 144. What &, + 1ean ) ST5#

1/

Ans: it is an advance application of template. #t contains several in b ilt f nction 1 operators that help the programmer to develop comple) program. 0he programmer needs to incl de the header file to se the f nction or operator li+e library f nction. 145. What "% the (,nta"ner ,' ST5# Ans: #t incl des mainly ! components: ,ontainer Algorithm #terator. 146. 6"-e an e2a1p.e that *".. %h,* a.. the ST5 (,1p,nent%# Ans: comp ter: container #cons on comp ter: algorithm , rsor: #terator. 147. What "% (,nta"ner# What are the t pe% ,' (,nta"ner# Ans: container is an object that contains all the data or other objects. #t is of ! types. 7%%,("at"-e (,nta"ner: it incl des set$ m lti set$ map 1 m lti map. Se8+en(e (,nta"ner: #t incl des vector$ deH e 1 list. 9er"-e& (,nta"ner: it incl des stac+$ H e e 1 priority 148. What &, + 1ean ) a./,r"th1 0 "terat,r# Ans: Algotithms are the application that is sed to carry o t the operation on the content. % t iterators behave li+e pointers 1 sed to access the element of container. 149. What "% the &"''eren(e )et*een -e(t,r 0 arra # Ans: Array is a collection of similar data types. #n array siEe is fi)ed. Fe canMt enter more element than the siEe given. % t vector is a dynamic array. Fe can add any no of element. ' ppose given dynamic int a Q12R. #f we want to enter 1. elements then it can be possible. A tomatically the siEe of array will be increased. 15$. What &, + 1ean ) %1art p,"nter# Ans: #terators are called as smart pointer. 0hey are sed by the algorithm to carry operations. 151. What "% the +%e ,' ."%t# Ans: list allows the insertion 1 deletion of item anywhere. #t can be accessed bidirectional. #t is defined in the header file BlistC.

12

Das könnte Ihnen auch gefallen