CPP新手:编译器错误

时间:2012-07-01 03:52:51

标签: c++

编译失败,输出如下。

请任何想法..

PStore.cpp
PStore.cpp(169) : error C2220: warning treated as error - no 'object' file generated
PStore.cpp(169) : warning C4091: '' : ignored on left of 'bool' when no variable is declared
PStore.cpp(169) : error C2143: syntax error : missing ';' before 'inline function header'
PStore.cpp(170) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
PStore.cpp(170) : error C2556: 'int PStore::getVersion(std::string &)' : overloaded function differs only by return type from 'bool PStore::getVersion(std::string &)'
    ../include\PStore.h(48) : see declaration of 'PStore::getVersion'
PStore.cpp(170) : error C2371: 'PStore::getVersion' : redefinition; different basic types
    ../include\PStore.h(48) : see declaration of 'PStore::getVersion'

以下是代码段:

bool PStore::getVersion(std::string& version)
{
    AMPI_INFO("[API]");

    return getVersionNoLogging(version);
}
bool PStore::getVersionNoLogging(std::string& version)
{
    version = AMPI_PStore_VERSION " " __DATE__ " " __TIME__;

    return true;
}

1 个答案:

答案 0 :(得分:5)

请发布您的代码,以便解释所有错误。

其中一个错误很明显:你不能拥有两个具有相同参数和相同名称的函数。

在您的情况下,您有int PStore::getVersion(std::string &)bool PStore::getVersion(std::string &),这是不合法的。

更改其中一个功能的名称,或更改其中一个功能的参数类型或数量。