I've heard and read many times that it is better to catch an exception as reference-to-const rather than as reference. Why is:
try {
// stuff
} catch (const std::exception& e) {
// stuff
}
better than:
try {
// stuff
} catch (std::exception& e) {
// stuff
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…