-->
当前位置:首页 > 题库 > 正文内容

单选题:What changes you can do in the header files to avoid the redefin

Luz3年前 (2022-03-01)题库812
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 <iostream.h>

using namespace std;

int func(int a)
{

cout<<"Multiplied by 2";
return 2*a;
}
------------------------------------------------

Content of h2.h
------------------------------------------------
//h2.h
#include <iostream.h>

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
C.Include one header files where they are needed so that no clashes occur
D.Make the header files name same


答案:B

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。