Wednesday, 9 July 2008

C++ Screening Questions

Q1) When you compile and run this program, what happens?

#include <iostream>
class A
{
public:
~A() { throw std::exception("whatever"); }
};
int main()
{
try
{
A a;
}
catch(...)
{
std::cout << "caught" <<>
}
}


A) it prints "caught" and exits normally
B) the output is undefined
C) the program exits with a call to std::terminate()
D) something quite different from any of the above

No comments: