I was given the following as an interview question:
class A
{
public:
void fun()
{
std::cout << "fun" << std::endl;
The most likely behavior, on most modern computers, is that it will run, and print "fun", because:
fun()
is not virtual, so there's no need to refer to a vtable to call fun()
fun()
never access any member variables in A
so it doesn't need to dereference
the null this
pointer.