Following are the differences between C & C++:
C | C++ |
1. C is Procedural Language. | 1. C++ is non Procedural i.e Object oriented Language. |
2. No virtual Functions are present in C | 2. The concept of virtual Functions are used in C++. |
3. In C, Polymorphism is not possible. | 3. The concept of polymorphism is used in C++. Polymorphism is the most Important Feature of OOPS. |
4. Operator overloading is not possible in C. | 4. Operator overloading is one of the greatest Feature of C++. |
5. Top down approach is used in Program | 5. Bottom up approach adopted in Program Design. |
6. No namespace Feature is present in C Language. | 6. Namespace Feature is present in C++ for |
7. Multiple Declaration of global variables are allowed. | 7. Multiple Declaration of global variables are not allowed. |
8. In C
| 8. In C++
|
9. Mapping between Data and Function is difficult and complicated. | 9. Mapping between Data and Function can be used using "Objects" |
10. In C, we can call main() Function through other Functions | 10. In C++, we cannot call main() Function through other functions. |
11. C requires all the variables to be defined at the starting of a scope. | 11. C++ allows the declaration of variable anywhere in the scope i.e at time of its First |
12. No | 12. Inheritance is possible in C++ |
13. In C, malloc() and calloc() Functions are used for | 13.In C++, new and delete operators are used for Memory Allocating and Deallocating. |
14. It supports built-in and primitive data types. | 14. It support both built-in and user define data types. |
15. In C, Exception Handling is not present. | 15. In C++, Exception Handling is done with Try and Catch block. |
16. ANSI C recognizes only the first 32 characters in identifier names. | 16. ANSI C++ places no limits on its length. |
17.In ANSI C, we can assign a void pointer to a non-void pointer without using a cast to non-void pointer type. For example: void *ptr1; char *ptr2; ptr2=ptr1; | 17. In ANSI C++ we must use cast operator as shown below: ptr2=(char *) ptr1; |
18. ANSI C does not require an initializer; if none is given, it initializes the const to 0 | 18. C++ requires a const to be initialized. |
19. In C character constants are stored as int, therefore, sizeof('a') is equivalent to sizeof(int) | 19. In C++ char is not promoted to the size of int, and therefore, sizeof('a') is equivalent to sizeof(char) |
20. In C, the global version of a variable cannot be accessed from within the inner block. | 20. In C++, this problem is resolved by the introduction of a new operator : : called the scope resolution operator. |
21. C notation for type casting is: (type) expression | 21. C++ notation for type casting is: type (expression) |
22. In C struct keyword is necessary while creating a object of structure. For example: struct student a; | 22. In C++ struct keyword is not necessary while creating a object of structure. For example: student a; |
No comments:
Post a Comment