Vidyalelo
C++ Programming · Q161

Functions and Procedures in C++

Programming · C++ Programming · question 161

Q161

What will be the output of the following C++ code? Content of header file h1.h ------------------------------------------------ h1.h #include using namespace std; namespace A int func(int a) cout using namespace std; namespace B float func(float a) cout #include #include "h1.h" #include "h2.h" using namespace std; using namespace A; using namespace B; int main(int argc, char const *argv[]) /* code */ int a = 10; float b = 10.0; cout<<func(a)<<endl; cout<<func(b); return 0; -----------------------------------------------

A.
using namespace A10
using namespace B10
B.
using namespace A20
using namespace B20
Answer
C.
Error due to clash of func()
D.
This is not allwed in C++

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board