0
scoped_refptr<any_class> a_scoped_refptr;
const scoped_refptr<any_class> something = a_scoped_refptr; // Compile error.

const の場合は ref_counter を変更できませんが、ポインターが指すコンテンツを変更してはならないことを暗示したいのですが、どうすればよいですか?

4

1 に答える 1

1

2つのこと:

最初に、コンパイラ エラーについて言及していませんでしたが、scoped_refptr.

次に、const オブジェクトへのポインターが必要な場合は、それをポインター型として指定します。だから試してください:

scoped_refptr<any_class const> myPointer = a_scoped_refptr;
于 2012-07-25T20:02:26.420 に答える