Difference Between C and C++

Difference Between C and C++

1. C is a subset of C++ when compared to C++ while C++ is a superset of C. C++ can run most of the C code while C cannot run C++ code.

2. C supports the procedural programming paradigm for code development while C++ supports both procedural programming and object-oriented programming paradigm. That's why C++ also called a hybrid language.

3. In C data and functions are separate and are free entities but In C++ data and functions are encapsulated together in the form of an object.

4. C uses functions for input/output e.g., scanf and printf while C++ uses objects for input/output e.g., cin and cout.

5. C provides malloc and calloc function for Dynamic Memory Allocation(DMA) and free for memory deallocation while C++ provides a new operator for memory allocation and delete operation for memory deallocation.

6. C does not provide direct support for error handling (also called exception handling) but C++ provides support for exception handling. Exceptions are practiced for "hard" errors that cause the code wrong.

Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.