Tuesday, May 22, 2007

C++ Interview Questions

Q: What about Virtual Destructor?
Ans: Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object baller is balling to , proper destructor will be called.
Q: What is Pure Virtual Function? Why and when it is used ?
Ans: The abstract class whose pure virtual method has to be implemented by all the classes which derive on these. Otherwise it would result in a compilation error. This construct should be used when one wants to ensure that all the derived classes implement the method defined as pure virtual in base class.
Q: Can inline functions have a recursion?
Ans: No. Syntax wise It is allowed. But then the function is no longer Inline. As the compiler will never know how deep the recursion is at compilation time.
Q: Explain the scope resolution operator?
Ans: It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.

No comments: