Examlex

Solved

The Following Program Has Been Partitioned into Two Files

question 14

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;
}


Definitions:

Retina

The light-sensitive layer at the back of the eye, containing cells that convert light into neural signals.

Optic Nerve

The optic nerve is a paired nerve that transmits visual information from the retina to the brain.

Iris

The colorful segment of the eye that modulates pupil dimension and the level of light that gets in.

Trichromatic Receptor Theory

A theory of color vision stating that the human eye has three types of receptors with differing sensitivities to light wavelengths, corresponding to red, green, and blue colors.

Related Questions