I found that there are three ways to catch an exception, what are the differences?
1) catch by value;
2) catch by reference;
3) catch by pointer;
I only know that catch by value will invoke two copies of the object, catch by reference will invoke one. So how about catch by pointer? When to use catch by pointer? In addition to throw an object, can I throw a pointer to an object like this?
class A {}
void f() {
A *p = new A();
throw p;
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…