The following program has been partitioned into two files.The command line command for compiling this is CC B.cpp A.cpp,where CC is the name for your command line compiler.For VC++ this is CL,for Borland,this is BCC32,and for the GNU C++ compiler,this is g++.If you use an IDE (integrated development environment)you would have to place both these files in your project then click the compile button.
Predict the output and explain your prediction.
// This goes in file A.cpp
namespace
{
int func(int i)
{
return i*3;
}
int junk (int i)
{
return i*func(i);
}
// This goes in file B.cpp
#include <iostream>
int func(int i)
{
return i*5;
}
int junk(int i);//from A.cpp
int main()
{
cout <<"func(5)= " << func(5)<< endl;
cout <<"junk(5)= " << junk(5)<< endl;
}
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q16: A function defined inside an unnamed namespace
Q17: The include statement,#include <file.h> looks in the
Q18: The include statement,#include "file.h" looks first in
Q19: You can have a name spelled the
Q20: An unnamed namespace provides a facility for
Q22: Here is some code.There are only two
Q23: The following program has been partitioned into
Q24: Carefully distinguish the using directive
using namespace std;
from
Q25: The output from the following code is
"function".
(The
Q26: Given the namespace groupings that contain
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents