CPP 的新手:编译器错误

new to CPP: Compiler error

本文关键字:编译器 错误 新手 CPP      更新时间:2023-10-16

编译失败,输出如下。

请有任何想法..

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 &)'
    ../includePStore.h(48) : see declaration of 'PStore::getVersion'
PStore.cpp(170) : error C2371: 'PStore::getVersion' : redefinition; different basic types
    ../includePStore.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;
}

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

但是,其中一个错误是显而易见的:您不能有两个具有相同参数和相同名称的函数。

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

更改其中一个

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