“函数已经有一个主体" [英] "function already has a body"
本文介绍了“函数已经有一个主体"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是什么意思?
1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.cpp(107): error C2084: function 'bool readXMLInteger(xmlNodePtr,const char *,int &)' already has a body
1>c:\users\vitali\documents\visual studio 2010\projects\salam\tools.h(52) : see previous definition of 'readXMLInteger'
tools.cpp(107):
tools.cpp(107):
bool readXMLInteger(xmlNodePtr node, const char* tag, int32_t& value)
{
char* nodeValue = (char*)xmlGetProp(node, (xmlChar*)tag);
if(nodeValue)
{
value = atoi(nodeValue);
xmlFreeXOXL(nodeValue);
return true;
}
return false;
}
tools.h(52)
tools.h(52)
bool readXMLInteger(xmlNodePtr node, const char* tag, int& value);
推荐答案
您是否在原始头文件中使用了包含保护?
Did you use include guards in your original header file?
例如:
#ifndef _TOOLS_H_
#define _TOOLS_H_
... your header body is here ...
#endif
这会阻止在每个包含它的 cpp 中重新定义.
This blocks against re-defining in each cpp where it is included.
这篇关于“函数已经有一个主体"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文