[ create a new paste ] login | about

Link: http://codepad.org/9x3Y4OQo    [ raw code | output | fork ]

Niels - C++, pasted on Aug 3:
#include <iostream>

class exception
{
  const char * m_what;
public:
  exception() throw()
  :
  m_what("X")
  {
  }

  exception(const exception& arg) throw()
  :
  m_what("copy of X")
  {
  }

  virtual const char * what() const throw()
  {
    return m_what;
  }
};

int main()
{
  using ::exception; // Similar to std::exception.
  try
  {
    throw exception(); // May do copy elision.
  }
  catch (const exception& e)
  {
    std::cout << e.what(); // "X" or "copy of X"???
  }
}


Output:
1
copy of X


Create a new paste based on this one


Comments: