Vidyalelo
C++ Programming · Q117

Functions and Procedures in C++

Programming · C++ Programming · question 117

Q117

What changes you can do in the header files to avoid the redefinition that compiler will give when both the header files are included in the same program keeping the declaration of both the functions same? Content of h1.h ------------------------------------------------ h1.h #include using namespace std; int func(int a) cout using namespace std; int func(int a) cout<<"divided by 2"; return a/2; ------------------------------------------------

A.
Cannot be handled because C++ does not allow this
B.
Declare both the function inside different namespaces
Answer
C.
Include one header files where they are needed so that no clashes occur
D.
Make the header files name same

Answer: Option B

Solution

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