Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
混合コード C++ アプリケーションで std とシステム例外をキャッチする正しい方法は何ですか?
このような?
try { // using pure C++ and managed components } catch(std::exception exp) { } catch(System::Exception sexp) { }
の派生例外のスライスを避けるために、参照によってそれらをキャッチしますstd::exception。
std::exception
catch (std::exception &exp)
このようにして、すべての派生例外を適切にキャッチできます。(多型)