リチャード・ギラムは、彼の「代入演算子の解剖学」の中で、彼の論文の冒頭で次のように述べているため、おそらく間違った発言をしています。
「この質問に対する 1 つの正解は次のようになります。」
TFoo&TFoo::operator=(const TFoo& that)
{
if (this != &that)
{
TBar* bar1 = 0;
TBar* bar2 = 0;
try
{
bar1 = new TBar(*that.fBar1);
bar2 = new TBar(*that.fBar2);
}
catch (...)
{
delete bar1;
delete bar2;
throw;
}
TSuperFoo::operator=(that);
delete fBar1;
fBar1 = bar1;
delete fBar2;
fBar2 = bar2;
}
return *this;
}
私は作者が間違っているとTSuperFoo::operator=()
思いbar1
ますbar2
。