問題タブ [raw-pointer]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - オーバーロード演算子のエラー>>
operator>>
クラス プレーンに使用しようとしましたが、 main()
. それは言う
私のメイン():
私の読み取り():
オペレーター>>
:
それは(.h)にあります:
friend std::istream& operator>> (std::istream& is, Aircraft& A);
それは(.cpp)にあります:
使い方としては、こんな感じで完璧です。
これで何が悪いのですか?
rust - Arc を含む構造体フィールドを書き込み可能にする方法は?
どうにかして生のポインターの形で取得する必要がある構造体があります。
そのフィールドに書き込む必要があるmap
ため、生のポインタを構造体に逆参照してから、そのデータ フィールドに書き込もうとします。しかし、次のエラーが発生しました。
map
フィールドを可変かつ書き込み可能にするにはどうすればよいですか?
このエラーは、次のコードを使用して再現できます。
箱:memmap = "0.6.2"
pointers - 生のポインターを使用することが多かれ少なかれ適切である場合、どのように判断すればよいですか?
Rust は安全性の高いシステムでの使用を想定している印象があります。次に、生のポインターを使用すると任意のポインター演算が可能になり、メモリの安全性とセキュリティの問題が発生する可能性があることに気付きました。
c++ - removing shared pointers from vector or map
I am currently in the process of learning smart pointers and try to avoid using raw pointers.
I have a vector with shared ptrs
and an Add and Remove method
Now in another part of my code I have a map
Now when I try to remove elements from the map like this:
Now the problem lies here : iterator->second.get()
It tells me it cannot convert the rvalue of type pointer to shared ptr.
However if I use raw pointers instead of shared pointers this is not an issue at at all.
So, I am wondering if in this case it would be better to just use raw pointers or can I work around this with shared pointers?