Essay
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
Compilers compliant with the S...View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q9: Any global declarations or definitions can be
Q10: You have a helping function that is
Q11: Here is some code.There are only two
Q12: If I have already written the #include
Q13: During name resolution,nested namespaces behave like nested
Q15: In a particular file,the names from the
Q16: A namespace is a collection of name
Q17: Suppose the following code is embedded
Q18: What is the problem that the C++
Q19: We are interested in providing a class,say