I formed a nice interview question by chance. :)
template<typename T>
bool foo (T obj)
{
  if(typeid(T) == typeid(obj))
    return false;
  return true;  // <-- execute this
}
You have to call (only above mentioned) foo() in such a way that it returns true. Conditions are,
foo() or typeid
#define allowed#include <cassert>
struct B { virtual ~B() {} };
int main()
{
    struct : B {} x;
    assert(foo<B&>(x));
}
Action is over there.
int main ()
{
  typedef char C[1];
  foo<C>(0);  // returns true;
}
Refer this question to know the explanation of this answer and root of this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With