XXXXXXXXXXAssignment 4 True False: Comment required. 1. Any global declarations or definitions can be placed in a namespace. 2. The include statement, #include looks in the system defined directory...

1 answer below »
i submitted assignment i answered already from 1 through 30 just wanted to the remaining questions to be completed under neath from 1 through 15


Assignment 4 True False: Comment required. 1. Any global declarations or definitions can be placed in a namespace. 2. The include statement, #include looks in the system defined directory for the file, file.h. (Windows PC and Macintosh users sometimes use “folder” for what I call “directory”.) <> in #include signal the preprocessor to look in the system directory. 3. In C++, a compilation unit is a class or function. . 4. A function defined inside an unnamed namespace requires qualification. 5. In a particular file, the names from the global namespace and names from an unnamed namespace defined in the file are accesses the same way: by writing the name. 6. If I just write code, it is not in any namespace. 7. The scope of a using directive or using declaration is from its position in the block to the end of the program. 8. You can have a name spelled the same in two different namespaces with no conflict in your program. . 9. You can use #define to define a name for a C++ variable. 10. If I have already written the #include header, I can overload operator< for="" class="" a="" as="" follows:="" std::ostream&="">< (std::ostream&="" out,const="" a&="" obj);="" 11.="" an="" input="" stream="" is="" a="" stream="" of="" data="" flowing="" from="" your="" program,="" either="" to="" a="" file,="" or="" to="" the="" keyboard.="" 12.="" cin="" is="" an="" output="" stream="" object="" of="" type="" ostream.="" 13.="" when="" a="" program="" sends="" data="" from="" itself="" to="" the="" outside,="" say="" to="" a="" file="" or="" the="" screen,="" we="" say="" it="" is="" writing="" the="" data="" on="" the="" file="" or="" to="" the="" screen.="" 14.="" an="" istream="" object="" is="" already="" an="" ifstream="" object="" with="" some="" extra,="" added="" features.="" an="" open="" member="" function="" that="" ties="" the="" stream="" to="" a="" file,="" but="" the="" istream="" objects="" do="" not.="" 15.="" when="" you="" write="" ifstream="" instream;="" instream.open(”infile.dat”);="" the="" file,="" infile.dat="" must="" be="" located="" in="" the="" directory="" where="" the="" program="" is="" being="" run.="" 16.="" a="" file="" is="" automatically="" closed="" when="" a="" program="" terminates,="" so="" there="" is="" never="" a="" need="" to="" close="" a="" file.="" 17.="" the="" flush="" member="" function="" copies="" the="" file="" buffer="" to="" the="" file="" on="" the="" file="" medium="" (disk,="" tape,="" etc).="" 18.="" setting="" the="" width="" of="" output="" with="" call="" to="" the="" width="" member="" function,="" affects="" only="" the="" next="" output.="" 19.="" setting="" the="" width="" of="" output="" with="" the="" manipulator="" setw="" is="" different="" from="" setting="" the="" width="" with="" the="" width="" member="" function.="" 20.="" if="" the="" output="" is="" too="" wide="" for="" the="" width="" specified="" in="" a="" setw="" manipulator="" or="" a="" call="" to="" the="" width="" member="" function,="" then="" the="" output="" is="" lost.="" 21.="" a="" recursive="" function="" is="" a="" function="" whose="" definition="" contains="" a="" call="" to="" the="" function="" being="" defined="" 22.="" it="" is="" proper="" for="" a="" recursion="" to="" run="" on="" without="" ending.="" 23.="" a="" proper="" recursive="" solution="" requires="" at="" least="" two="" cases:="" a="" recursive="" function="" that="" calls="" the="" recursive="" function="" with="" a="" smaller="" problem,="" and="" a="" base,="" or="" stopping="" case.="" 24.="" a="" recursive="" function="" must="" not="" return="" a="" value.="" 25.="" a="" recursive="" function="" can="" have="" local="" variables.="" 26.="" a="" recursive="" function="" can="" have="" only="" one="" recursive="" case.="" 27.="" each="" activation="" frame="" contains="" all="" the="" function’s="" code,="" as="" well="" as="" the="" automatic="" variables="" and="" formal="" parameters.="" 28.="" the="" activation="" frames="" in="" nested="" function="" calls="" are="" handled="" in="" a="" last-in/="" first-out="" order.="" 29.="" a="" binary="" search="" works="" with="" any="" array="" of="" numbers.="" 30.="" for="" the="" binary="" search="" in="" the="" text="" to="" work,="" the="" element="" searched="" for="" must="" actually="" be="" present="" in="" the="" array.="" multiple="" choice="" 1.="" select="" the="" correct="" rules="" for="" encapsulation.="" if="" any="" rules="" need="" to="" be="" imposed="" in="" a="" particular="" order,="" then="" say="" so,="" mentioning="" which="" rules.="" a)="" make="" all="" class="" member="" variables="" public="" members="" of="" the="" class.="" b)="" place="" the="" interface="" in="" the="" header="" file.="" what="" is="" the="" interface?="" c)="" place="" the="" implementation="" in="" a="" separate="" code="" file="" (with="" file="" extension="" required="" by="" your="" compiler:="" .cpp,="" .cxx,="" etc),="" called="" the="" implementation="" file.="" what="" is="" the="" implementation?="" d)="" having="" private="" members="" visible="" in="" the="" interface="" violates="" the="" philosophy="" of="" separating="" the="" interface="" from="" the="" implementation.="" separate="" interface="" and="" implementation="" requires="" removal="" of="" all="" the="" private="" members="" from="" the="" class="" definition.="" you="" must="" put="" these="" in="" another="" part="" of="" the="" class="" definition="" in="" the="" implementation.="" 2.="" some="" of="" the="" statements="" about="" separate="" compilation="" follow.="" which="" are="" correct?="" comment="" on="" all="" the="" answers="" in="" the="" explanation="" section,="" including="" the="" ones="" that="" are="" wrong.="" a)="" separate="" files="" are="" a="" big="" bother.="" there="" is="" no="" compelling="" advantage="" to="" separate="" files.="" b)="" placing="" client="" and="" class="" implementations="" in="" separate="" files="" enhances="" project="" development.="" how?="" c)="" separate="" files="" for="" interface="" and="" implementation="" enhance="" reuse.="" how?="" d)="" separating="" interface="" and="" implementation="" can="" save="" considerable="" time.="" how?="" 3.which="" of="" the="" following="" are="" the="" correct="" preprocessor="" commands="" necessary="" to="" prevent="" multiple="" inclusions="" of="" header="" files?="" if="" there="" is="" an="" answer="" here="" that="" works="" to="" prevent="" multiple="" inclusion,="" carefully="" describe="" how="" it="" works="" in="" the="" explanation.="" a)#include="" “header.h”="" b)#define="" header_h="" #ifndef="" header_h="" declarations="" for="" header.h="" go="" here="" #endif="" c)#ifndef="" header_h="" #define="" header_h="" declarations="" for="" header.h="" go="" here="" #endif="" d)#ifndef="" header_h="" declarations="" for="" header.h="" go="" here="" #endif="" 2.="" you="" are="" defining="" a="" class="" for="" use="" in="" a="" program="" you="" are="" writing.="" which="" of="" the="">>>>ADD: “a” lowwercse following should be placed in the interface file for your class? Which should be placed in the implementation file for your class? a) The class definition. b) The declaration of a stand-alone function (neither member nor friend of the class) that uses this class type parameter, and is used as a class operation. c) The declaration of a stand-alone overloaded operator (neither member nor friend of the class) that is to serve as a class operation. d) The definition of a stand-alone function (neither member nor friend of the class) that uses this class type parameter, and is to serve as a class operation. e) The definition of a friend function that is to serve as a class operation. f) The definition of a member function. g) The definition of a stand-alone overloaded operator (neither member nor friend of the class) that is to serve as a class operation. h) The definition of an overloaded operator that is to serve as a class operation and is a friend of the class. i) The main function of your program. 3. Here is a list of file names with extensions. Pick at least one that could properly be the implementation file and at least one that can properly serve as interface file. a) File.cxx b) File.hxx c) File.cc d) File.h e) File.cpp f) File.hpp 4. Of the interface file and the implementation file, which may be directly compiled? a) Only the interface? b) Only the implementation? c) None of the above? d) Some of the above? Which? 5. Which of the following sets of statements will set floating point output to the stream outStream to fixed point with set 3 places of decimals? In the explanation, you must give any necessary #include directives and using directives or declarations. a) outStream.setf(ios::fixed); outStream.setf(ios::showpoint); outStream.precision(2); b) outStream.setf(ios::fixed | ios::showpoint); outStream < setprecision(2);="" c)="" outstream="">< setflag(ios::fixed);="" outstream="">< setflag(ios::showpoint);="" outstream="">< setprecision(2);="" d)="" outstream.flags(ios::fixed);="" outstream.flags(ios::showpoint);="" outstream.precision(2);="" 7.to="" clear="" the="" show="" plus="" sign="" flag="" but="" leave="" the="" rest="" of="" the="" flags="" alone,="" you="" use="" the="" _____________="" member="" function="" and="" argument.="" e)="" setf(!="" ios::showpos);="" f)="" setprecision(ios::showpos);="" g)="" unsetf(ios::showpos);="" h)="" setf(ios::showneg);="" i)="" unsetf(!="" ios::showneg);="" 8.to="" determine="" whether="" a="" file="" was="" opened="" successfully,="" one="" can="" use="" the="" ___________="" fstream="" member="" function="" j)="" close(="" )="" k)="" overloaded="" operator=""><( )="" l)="" open(="" )="" m)="" eof(="" )="" n)="" flush(="" )="" 9-the="" ____________="" fstream="" member="" function="" closes="" a="" file="" stream.="" explain="" why="" it="" is="" best="" to="" close="" a="" file="" when="" the="" program="" is="" through="" processing="" the="" data="" in="" the="" file.="" o)="" close(="" )="" p)="" overloaded="" operator=""><( )="" open(="" )="" q)="" eof(="" )="" r)="" flush(="" )="" 10-the="" _______="" member="" function="" takes="" a="" single="" char="" value="" from="" the="" input="" file,="" without="" regard="" to="" whether="" it="" is="" whitespace.="" s)="" newline="" t)="" get="" u)="" put="" v)="" getline="" w)="" putline="" 11-="" how="" many="" times="" is="" the="" following="" code="" invoked="" by="" the="" call="" recursive(4)?="" void="" recursive(="" int="" i="" )="" {="" using="" namespace="" std;="" if="" (i="">< 8)="" {="" cout="">< i="">< "="" ";="" recursive(i);="" }="" }="" a)="" 2="" b)="" 4="" c)="" 8="" d)="" 32="" 12-give="" the="" output="" of="" the="" recursive="" function="" below="" when="" called="" with="" an="" argument="" of="" 5.="" void="" recursive(="" int="" i="" )="" {="" using="" namespace="" std;="" if="" (="" i="">< 8="" )="" {="" i++;="" recursive(i);="" cout="">< i="">< "="" ";="" }="" }="" a)="" 6="" 7="" 8="" b)="" 5="" 6="" 7="" c)="" 8="" 7="" 6="" d)="" 7="" 6="" 5="" e)="" none="" of="" the="" above.="" this="" is="" an="" infinite="" recursion="" if="" the="" function="" is="" called="" with="" argument="" 5.="" 13-here="" is="" recursive="" function.="" identify="" the="" recursive="" case="" and="" the="" default="" case.="" void="" recursive(="" int="" i="" )="" a)="" {="" if="" (="" i="">< 8="" )="" b)="" {="" i++;="" c)="" recursive(i);="" d)="" cout="">< i="">< " "; //e) } } //f) the base case is not explicitly listed. if you choose this answer, // then you must explain what "="" ";="" e)="" }="" }="" f)="" the="" base="" case="" is="" not="" explicitly="" listed.="" if="" you="" choose="" this="" answer,="" then="" you="" must="" explain="">
Answered Same DayJan 22, 2022

Answer To: XXXXXXXXXXAssignment 4 True False: Comment required. 1. Any global declarations or definitions can...

Salony answered on Jan 23 2022
117 Votes
Assignment MCQ
1.Answer Option (C)
Implementation file are those which are used when class declar
es. It contain all methods of class and it’s definitions . It declare inside header file. It included as “filename.h”
Answer 2
Option (a) is wrong because separate files help when we have to recompile a file, there is no need to recompile the whole project , just one file works
Option (b) class implementation file contain method definition which need not to change again and again but client requirement will change accordingly. So, keeping them separate no need to compile implementation file again
Option(c) It is prefer that we need to define member function in Implementation file in...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here