Qualcomm Interview Question: C++ Qs : virtual functions an... | Glassdoor

Interview Question

Software Engineer Interview San Diego, CA

C++ Qs : virtual functions and function overloading

Answer

Interview Answer

2 Answers

0

virtual function is a function in the parent class that allows to be overridden (allowing for dynamic polymorphism).
with virtual function (in C++) there is a special virtual pointer table that is generated by compiler to track functions ). hence sizeof(class) will be usual size + sizeof(ptr)
if function is not declared virtual and overridden always the function in parent gets called.

Anonymous on Oct 27, 2011
3

multiplication by 7 = multiplication by (8 - 1)

long 7mul_without_star(int n){

  return ((n << 3) - n);
}

Anonymous on Oct 27, 2011

Add Answers or Comments

To comment on this, Sign In or Sign Up.