Saturday, 5 July 2014

C++ Interview Questions and Answers

  1. What is the difference between new/delete and malloc(), free()?
  2. What if we allocate memory using new and release it with free()?
  3. Why do we need virtual destructors?
  4. C++ compiler provides a copy costructor and overloaded assignment operator by default, why do we need to write our own copy constructors?
  5. Have you ever used STL, why do we use STL, if yes then what containers?
  6. What are function pointers?
  7. What happens when a callback funtion is called?
  8. Differences between C and C++?
  9. Write a program in C language which prints "Hello World!" on screen, without using even a single semi colon ';'.
  10. Swap two integers without using a third one.
  11. Why do we need pure virtual functions?
  12. What are friend functions?



    For answers, Click here



    And now, some questions for practice, you will have to find the answers by yourself.
    Feel free to write the answers to these questions in the comments.
  13. What is the difference between a pointer and array?
  14. Is it possible to find out the size of an array?
  15. What is NULL?
  16. How can we find if a pointer contains a valid value or not?
  17. We have a circular linked list, and its tail -> next is not pointing to List -> Head. How can we diagnose such an error condition? 

For more questions to practice, click on the Questions??? tab and access the world of C++ questions and answers.