For string types, what's the difference between using push_back and directly concatenating characters with +?

I did a question on leetcode, but for the string type, the push_back concatenation character failed the test, but changed to the plus sign to concatenate the character and passed it.
topic link

my two codes:

class Solution {
public:
    vector<string> generateParenthesis(int n) {
        vector<string> res;
        string part = "";

        __generateParenthesis(res, part, n, n);

        return res;
    }

    void __generateParenthesis(vector<string> &res, string part, int left, int right) {
        if (left == 0 && right == 0) {
            res.push_back(part);
            return ;
        }

        if (left > 0) {
            part.push_back("(");

            __generateParenthesis(res, part, left - 1, right);
        }
        if (right > 0 && left < right) {
            part.push_back(")");
            __generateParenthesis(res, part, left, right - 1);
        }
    }
};

the above is not passable, but the following is passable:

class Solution {
public:
    vector<string> generateParenthesis(int n) {
        vector<string> res;
        string part = "";

        __generateParenthesis(res, part, n, n);

        return res;
    }

    void __generateParenthesis(vector<string> &res, string part, int left, int right) {
        if (left == 0 && right == 0) {
            res.push_back(part);
            return ;
        }

        if (left > 0) {
            // part.push_back("(");

            __generateParenthesis(res, part + "(", left - 1, right);
        }
        if (right > 0 && left < right) {
            // part.push_back(")");
            __generateParenthesis(res, part + ")", left, right - 1);
        }
    }
};

I don"t quite understand. I hope the seniors can give me some guidance.

Mar.03,2021

when you use operator+ , it is sent by value and has not changed part . When push_back () , change part , in the third if , the value of part does not match your expectation. You change the second example to string temp = part; temp.push_back (.); _ generateP. (., temp,.); should also be able to AC.

when PS: is on its own, don't use your own plan. I don't know where you learned it. You must reject it in cPP, because these words are reserved and reserved for standard use. Once you have such a name, it is UB. So when you watch py, it's always very uncomfortable.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b322c5-2bde7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b322c5-2bde7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?