Interfaces
- What is the output of this program?
#include
using namespace std;
namespace first
{
int num = 5;
}
namespace second
{
int num = 11;
}
int main ()
{
int num = 27;
first::num;
second::num;
cout << num;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, as there is lot of variable a and it is printing the value inside the block because it got the highest priority.
- What is the output of this program?
#include
using namespace std;
namespace calc
{
int p = 12;
}
namespace calc
{
int q = 23;
}
int main(int argc, char * argv[])
{
calc::p = calc::q =6;
cout << calc::p << calc::q;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
We are overriding the value at the main function and so we are getting the output as 66.
- What is the output of this program?
#include
using namespace std;
namespace calculation
{
int p;
}
void p()
{
using namespace calculation;
int p;
p = 15;
cout << p;
}
int main()
{
enum letter { K, L};
class K { letter L; };
::p();
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A scope resolution operator without a scope qualifier refers to the global namespace.