メソッドのシグネチャをオブジェクト所有者船が変更されたかどうかにコードする方法はありますか?ポインタを受け取ったり返すGetter()とSetter()では、オブジェクトの所有権が変更されるかどうかは決して分かりません。メソッドのオブジェクト所有権の命名規則
について、あなたはどう思いますか:(PUT対
// Uses pConfiguration or creates its own copy - the ownership is un-touched
void ContainerClass:SetConfiguration(const Configuration* pConfiguration) {}
// Takes the ownership of pConfiguration (and deletes it in the destructor)
void ContainerClass:PutConfiguration(Configuration* pConfiguration) {}
// Returns a 'reference' and keeps the ownership (you must not delete it)
const Configuration* ContainerClass::GetConfiguration() {}
// Returns a _new_ object and transfers the ownership to you
Configuration* ContainerClass::TakeConfiguration() {}
Soは(設定されている)、()と(取得)対()はそれをコーディングするための方法を取るか、タイプを使用するのconst対非const) - またはそれを文脈から知っていますか?
よろしく、
チャーリー
スマートポインタについて調べましたか?この種の問題を避けることができます。 – Naveen
えええええええええええええええええええええええええええええええええええええええええええええもう...私は考えなければならない - すべての私の問題を解決する場合:) – Charly