title: Where does exception object have its space, heap or stack, and how to access it in different class?
body: <p>Recently an interviewer asked me <strong>where the exception object in C++ is allocated, heap or stack?</strong> I'm not sure but I answered stack since I thought there is no "new" or "malloc". Is it correct?</p>
  
  <p>Then he kept asking me that <strong>if it's on stack,  assuming class A throw a exception object, let's say "e", and class B catch "e". Since "e" is on the stack of A, then how does B can have the access to this "e"?</strong></p>
  
  <p>I'm not very clear about the second question. Could anyone can give me some example code showing that "class A throw e and class B catch it"? Also, I guessed B can catch e by copying the value or address but the interviewer only denied my answer without giving me right one, so what is the right answer, is there any mechanism can ensure class object can catch exceptions from other class objects? Thanks~</p>