Sunday, June 7, 2020

Difference Between C & C++

There are following differences between C and C++:
  1. C++ is derived from C language. It is super set of C.
  2. Earlier C++ was known as C with classes.
  3. In C++, the major change was the addition of classes and a mechanism for inheriting class objects into other classes.
  4. Most C programs can be compiled in C++ compiler.
  5. C++ expressions are the same as C expressions.
  6. All C operators are valid in C++.
  7. C is procedural language whereas C++ is non procedural language i.e. object oriented language.
  8. No virtual functions are present in C. The concept of virtual functions are used in C++.
  9. In C, Polymorphism is not possible. The concept of polymorphism is used in C++.
  10. Operator overloading is not possible in C. Operator overloading is one of the greatest feature of C++.
  11. Top down approach is used in program design in C. Bottom up approach adopted in program design in C++.
  12. No namespace feature is present in C language. Namespace feature is present in C++ for avoiding name collision.
  13. Multiple declaration of global variables are allowed in C. Multiple declaration of global variables are not allowed in C++.
  14. In C, mapping between data and function is difficult and complicated. In C++, mapping between data and function can be used using 'objects'.
  15. In C, we can call main() function through other function. In C++, we can't call main() function through other function.
  16. C requires all the variables to be defined at the starting of a scope. C++ allows the declaration of variable anywhere in the scope i.e. at time of its first use.
  17. No inheritance is possible in C. Inheritance is possible in C++.

No comments:

Post a Comment