-1

次の出力でコンパイルが失敗します。

どんな考えでもしてください..

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;
}
4

1 に答える 1

5

すべてのエラーを説明できるように、コードを投稿してください。

ただし、エラーの 1 つは明らかです。同じパラメーターと同じ名前を持つ 2 つの関数を使用することはできません。

あなたの場合、合法ではないint PStore::getVersion(std::string &)andがあります。bool PStore::getVersion(std::string &)

いずれかの関数の名前を変更するか、いずれかの関数のパラメーターの型または数を変更してください。

于 2012-07-01T03:56:07.673 に答える