newAcct = oldAcct; the following steps take place:
class Foo { public: Foo ( std::string s, int index ) : _name(s), _index(index){};
Foo(const Foo& rhs):_name(rhs._name){ _index = rhs._index; }
// Copy assignment Foo& operator=(const Foo& rhs){
// Guard against self-assignment
if ( &rhs != this ){
_name.clear();
// invokes string::oprator=(const string&)
_name = rhs._name;
_index = rhs._index;
}
return *this; }
std::string _name; int _index; };
int main(){ Foo f1(“qwddf”, 54); Foo f2 = f1; std::cout « f2._name « ”, “ « f2._index « “\n”; } ```