I was given the following as an interview question:
class A { public: void fun() { std::cout << "fun" << std::endl;
I have tried multiple times,all the time output is coming "fun" this is because function fun is independent of instance a. while calling a->fun(); a points to 0 so this is undefined behavior but in most of the compilers there should be no crash.
fun
a
a->fun();