Saturday, 11 October 2014

Differences between C and C++


C and C++ are very important programming languages. As C is older than C++ there some difference between C and C++ language. They are:
1. C is Procedural Language but C++ is  multi-paradigm language i.e. procedural as well as object oriented.

2. The concept of virtual Functions are used in C++ but No virtual Functions are present in C.

3. In C Top down approach is used in Program Design where in C++ Bottom up approach adopted in Program Design.

4. No namespace Feature is present in C Language as it is not needed but Namespace Feature is present in C++ for avoiding Name collision example "using namespace std;".

5. Multiple Declaration of global variables are alloed in C but Multiple Declaration of global varioables are not allowed in C++.

6. In C scanf() Function used for Input and printf() Function used for output but in C++ Cin>> Function used for Input and Cout<< Function used for output.

7. Polymorphism is not possible in C but in C++ the concept of polymorphism is used.

8. Operator overloading is not possible in C where Operator overloading is a Feature of C++.

9. Mapping between Data and Function is difficult and complicated in C programming Mapping between Data and Function can be used using "Objects" in C++ programming.

10. In C, we can call main() Function through other Functions in that programming but in C++, we cannot call main() Function through other functions.

11. No inheritance is possible in C where Inheritance is possible in C++.

12. In C, malloc() and calloc() Functions are used for Memory Allocation and free() function for memory Deallocating where In C++,  new and delete operators are used for Memory Allocating and Deallocating.

13. In C, Exception Handling is not present where in C++, Exception Handling is done with Try and Catch block.

14. 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.

15. We can use functions inside structures in C++ programming but not in C programming.

16. We can say C is low level language but C++ is middle-level language.

17. C++ supports Exception Handling while C does not.

18. In case of C, the data is not secured but for C++, the data is secured.

1 comment: