What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?
1. s = s + t;
2. s += t;
What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc),
First, where is the implementation of String? How can we answer a question if we don't see what "String" is and its implementation? Maybe the implementation is awful for operator += and great for operator + (or vice-versa).
Second, even if we saw the implementation, asking "how many copies are made" cannot be answered, because there is no answer. Copying objects and how many copies are made is solely up to the compiler and compiler settings when it comes to C++. The "how many copies are made" is a trick question.
also the Big O notation.
There is no "Big O" for this, unless there is a specific algorithm being implemented. You can't judge how fast or how slow high-level C++ code is unless it is obvious (i.e. a nested loop that is done "N" times for each loop is obviously N^2, a binary tree search is obviously logarithmic, etc.).
Too many times, we have newbie C++ or even veteran C coders (who are not experienced C++ coders) trying to eyeball high-level C++ code and determine what is fast or slow. What winds up happening is that their predictions are usually wrong.