Quantcast
Viewing all articles
Browse latest Browse all 8

接口用std::string const std::string& const char*的情况

string传值方式效率肯定是有问题的,如果使用引用方式,则必须提供原生指针接口,否则会有异常

void Test(const std::string& strParam)
{
strParam.c_str();
}
void Test(const char* szParam)
{
}
void Test()
{
Test(nullptr);
int i = 0;
i++;
std::string strA = "---";
}
Image may be NSFW.
Clik here to view.


Enic 2014-11-07 14:47 发表评论

Viewing all articles
Browse latest Browse all 8

Trending Articles