keywords: [C++]cannot convert argument 1 from ‘const char [5]’ to ‘std::string &’

Compiling Error:

error C2664: 'void TestFun01(std::string &)': cannot convert argument 1 from 'const char [5]' to 'std::string &'

Solution:

add const to std::string& which is a parameter of function, like this:

void TestFun01(const std::string& text)
{
    std::cout << text;
}

void TestFun02()
{
    TestFun01("abcd");
}

this would produce compilation error:

void TestFun01(std::string& text)
{
    std::cout << text;
}

void TestFun02()
{
    TestFun01("abcd");
}

人,越有智慧越显得孤独苦恼。