Programming with Passion

Make the best out of everything.

Friday, 8 April 2016

What is difference between C and C++ ?

1. What is difference between C and C++ ?
[This is a usual C or C++ interview question, mostly the first one you will face if you are fresher or appearing for campus interview. When answering this question please make sure you don't give the text book type explanations, instead give examples from real software scenario. Answer for this interview question can include below points, though its not complete list. This question itself can be a 1day interview !!!]

  1. C++ is Multi-Paradigm ( not pure OOP, supports both procedural and object oriented) while C follows procedural style programming.
  2. In C data security is less, but in C++ you can use modifiers for your class members to make it inaccessible from outside.
  3. C follows top-down approach ( solution is created in step by step manner, like each step is processed into details as we proceed ) but C++ follows a bottom-up approach ( where base elements are established first and are linked to make complex solutions ).
  4. C++ supports function overloading while C does not support it.
  5. C++ allows use of functions in structures, but C does not permit that.
  6. C++ supports reference variables ( two variables can point to same memory location ). C does not support this.
  7. C does not have a built in exception handling framework, though we can emulate it with other mechanism. C++ directly supports exception handling, which makes life of developer easy.

No comments:

Post a Comment