Professional Documents
Culture Documents
CPP Quirks
CPP Quirks
CPP Quirks
platform.
-> access violation would cause an exception to be thrown.
virtual! }
A: Yes if an exception is thrown inside the ctor, the dtor is never called. Solution: The same as before make m_r a RAII class.
Case AUDIO_FMT_AC3:
y ismdAudioFormat = ISMD_ AUDIO_FMT_AC3;
Case AUDIO_FMT_TRUEHD:
y ismdAudioFormat = ISMD_ AUDIO_FMT_TRUEHD;
y y y y
[audioFormat];
Q: How to get a strong guarantee? Solution: Use the pImpl idiom, followed by the copy-and-swap strategy.
PMImpl(*pImpl)); // Copy the data. y pNew->ReallyChangeState(); // modify the copy. y swap(pImpl, pNew); }
unless required.
Good References
and Effective STL \ Scott Meyers y Code Complete, 2nd Ed. \ Steve McConnell
Guidelines, and Best Practices \ Herb Sutter & Andrei Alexandrescu y The Pragmatic Programmer \ Andrew Hunt & David Thomas