C++ では、operator=不変であるべきクラスで定義する慣用的な方法は何ですか。たとえば、すべてのメンバー変数はconst.
typedef unsigned char byte;
class Binary
{
protected:
const unsigned long size;
const byte* bytes;
public:
Binary(const unsigned long size);
Binary(const Binary &b);
~Binary(void);
Binary& operator=(const Binary &b);
};
ここで、実行時に ed されるbytesメモリ ブロックへのポインタです。malloc
空の代入演算子を定義するか、明らかに失敗する自動生成された演算子を使用しますか?
いくつかの選択したクラスで単一の割り当てセマンティクスを実装および適用しようとしています。