The following program has been partitioned into two files.Before we commented out the keyword namespace and the curly braces that were around func(int)this program compiled and had this output:
func(5)= 25
junk(5)= 75
Will the code compile now? If so,predict the output and explain.
// 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
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
Q21: The following program has been partitioned into
Q22: Here is some code.There are only two
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
Q27: You can declare several names from a
Q28: What is the problem that the C++
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