user57606: in this code:
    void AdptSendReply(const char* str)
{
    string s(strlen(str) + 2);
    s = str;
    AdptSendReply(s);
}

void AdptSendReply(const string& str)
{
    string s(str.length() + 2);
    AdptSendReply(s); // use the next one
}

void AdptSendReply(string& str)
{
    if (AdapterConfig::instance()->getBoolProperty(PAR_LINEFEED)) {
        str += "\r\n";
        AdptSendString(str);
    }
    else {
        str += "\r";
        AdptSendString(str);
    }
}

i think c++ use of overloading ability.but how it can recognize which of the two functions "void AdptSendReply(string& str)" or "void AdptSendReply(const string& str)" must use?!

user55899: Calling overloading function triggers a process called overload resolution, which uses argument types to select the proper function to call

If you supply an lvalue argument of type string, the compiler will call void AdptSendReply(string& str) version. 
string s = "hello";
AdptSendReply(s); // calls 'string& str' version

If you supply an lvalue argument of type const string, the compiler will call void AdptSendReply(const string& str) version.
const string s = "hello";
AdptSendReply(s); // calls 'const string& str' version

If you supply an rvalue argument, the compiler will call void AdptSendReply(const string& str) version.
AdptSendReply(string("hello")); // calls 'const string& str' version


And so on. The full set of rules that govern overload resolution is quite extensive, especially when the context involves implicit conversions.

It is not clear what you mean by "must use". Normally, overloaded functions will do the same thing (functionality-wise), meaning that you are not supposed to worry about which function to use. Just call it with the argument you have available and the compiler will select the proper function to call.
Also, what is string? How are we supposed to know that? Without knowing it, your question make little sense.

57606: <p>in this code:</p>

<pre><code>    void AdptSendReply(const char* str)
{
    string s(strlen(str) + 2);
    s = str;
    AdptSendReply(s);
}

void AdptSendReply(const string&amp; str)
{
    string s(str.length() + 2);
    AdptSendReply(s); // use the next one
}

void AdptSendReply(string&amp; str)
{
    if (AdapterConfig::instance()-&gt;getBoolProperty(PAR_LINEFEED)) {
        str += "\r\n";
        AdptSendString(str);
    }
    else {
        str += "\r";
        AdptSendString(str);
    }
}
</code></pre>

<p>i think c++ use of overloading ability.but how it can recognize which of the two functions "void AdptSendReply(string&amp; str)" or "void AdptSendReply(const string&amp; str)" must use?!</p>
 55899: <p>Calling overloading function triggers a process called <em>overload resolution</em>, which uses argument types to select the proper function to call</p>

<ul>
<li><p>If you supply an lvalue argument of type <code>string</code>, the compiler will call <code>void AdptSendReply(string&amp; str)</code> version. </p>

<pre><code>string s = "hello";
AdptSendReply(s); // calls 'string&amp; str' version
</code></pre></li>
<li><p>If you supply an lvalue argument of type <code>const string</code>, the compiler will call <code>void AdptSendReply(const string&amp; str)</code> version.</p>

<pre><code>const string s = "hello";
AdptSendReply(s); // calls 'const string&amp; str' version
</code></pre></li>
<li><p>If you supply an rvalue argument, the compiler will call <code>void AdptSendReply(const string&amp; str)</code> version.</p>

<pre><code>AdptSendReply(string("hello")); // calls 'const string&amp; str' version
</code></pre></li>
</ul>

<p>And so on. The full set of rules that govern overload resolution is quite extensive, especially when the context involves implicit conversions.</p>

<hr>

<p>It is not clear what you mean by "must use". Normally, overloaded functions will do the same thing (functionality-wise), meaning that you are not supposed to worry about which function to use. Just call it with the argument you have available and the compiler will select the proper function to call.</p>

<p>Also, what is <code>string</code>? How are we supposed to know that? Without knowing it, your question make little sense.</p>
