简体   繁体   English

CPP的新功能:编译器错误

[英]new to CPP: Compiler error

Compilation fails with the following output. 编译失败,并显示以下输出。

Any thoughts please.. 有什么想法请..

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'

Here is the code snippet: 这是代码片段:

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

Please post your code so that all errors can be explained. 请发布您的代码,以便可以解释所有错误。

One of the errors is obvious however: you can't have two functions with the same parameters and the same name. 但是,其中一个错误是显而易见的:您不能拥有两个具有相同参数和相同名称的函数。

In your case you have int PStore::getVersion(std::string &) and bool PStore::getVersion(std::string &) , which is not legal. 在您的情况下,您有int PStore::getVersion(std::string &)bool PStore::getVersion(std::string &) ,这是不合法的。

Either change the name of one of the functions, or change the type or number of parameters of one of the functions. 更改功能之一的名称,或更改功能之一的参数的类型或数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM