C and C++ or ‘C with Classes’ are programming languages that are very popular and widely used in development environments. The major difference between C and C++ is, C only supports procedural language whereas C++ is an upgraded version of C as it supports object oriented programming as well asĀ procedural programming.
Difference between C and C++ in Tabular Form
Basis | C | C++ |
---|---|---|
Programming language Type | Procedural programming language | Multi-paradigm programming language as it supports OOPs, procedural programming and functional programming. |
OOPs features | Doesn't support OOPs features | It supports OOPs features ranging from Classes to Polymorphism |
Dynamic memory allocation | malloc(),realloc() and calloc() functions are used for dynamic memory allocation | "new"' operator is used for this purpose |
Memory Deallocation | free() is used to deallocate memory | delete operator is used to release memory |
Overloading | Function overloading and Operator overloading are not supported | Function overloading and Operator overloading are supported |
Focuses on | Method and process | Method and procedure |
Datatypes | Only Built-in is supported | Only Built-in and user defined data types are supported |
Reserved Keywords | 32 | 52 |
Virtual ,inline and friend functions | Not Supported | Supported |
Exception handling | Not supported | Supported |
Header file for Standard input and output | iostream | stdio.h/cstdio |
Input and output operations | scanf and printf | cin and cout |
Inheritance | Not Supported | Supported |
Reference Variable | Not Supported | Supported |
Namespace | Not Supported | Supported |
Information hiding | Not supported | Encapsulation feature is used for hiding data |
Polymorphism | Not supported | Supported |
Approach | Follows Top-Down approach | bottom-up approach |
Extension | A program is saved with file extension .c | A program is saved with file extension .cpp |
Developed by | Dennis Ritchie | Bjarne Stroustrup |
Driven by | Function-driven | Object-driven |
Successor of | B language | C language |
C Programming Language
It is a general purpose and procedural programming language that was initially developed by Dennis Ritchie at AT & T’s Bell Laboratories of USA in 1972.At the beginning, it was intended to be a language for developing operating systems and system related applications. Further, It supports vast community and is very popular language that you can learn and find solution of problem easily, if you get stuck.
Features of C:
– Easy to learn
– System programming language
– Code reusablity
– Vast community
– Can be used for developing a large range of applications
C++ Programming Language
C with Classes or C++ is an upgraded version of C programming language. It was developed by Bjarne Stroustrup at bell labs in 1985.
It is a modern programming language that provides support for OOPs features, such as Classes, Abstraction, Inheritance, Polymorphism and more.
It can be viewed as intermediate language as it has features of procedural language as well as Object oriented programming language. Though, C++ has the features of OOPs but it can’t be considered as completely object oriented.
Features of C++:
– Support for OOPs features
– Easy to learn and understand
– Exception handling
– Allow Operator Overloading
– Support for generic programming
Key Differences
- Dennis Ritchie at AT&T Bell Laboratories developed the C programming language, whereas; in the year of 1979, Bjarne Stroustrup developed the C++ programming language.
- C language does not support object-oriented programming approaches which clearly means that there is no support for inheritance, polymorphism, and encapsulation, etc., whereas; C++ language supports object-oriented programming approach which clearly indicates that there is support for inheritance, polymorphism and encapsulation, etc.
- C++ language codes cannot be run on C language platform which means that C is a subset of C++ language, whereas; C language codes can be executed on C++ language platform which means that C++ is a superset of the C language.
- In the C programming language, there is clear support for only procedural programming paradigm for writing the code, whereas; in the C++ programming language there is a combination of object-oriented paradigm and also procedural programming paradigm.
- The C language is a Procedural programming language which means that the function and data are kept away from each other, whereas; the C++ language there is a concept of objects which contains both the function as well as data.
- As the C programming is comparatively old as compared to C++ and thus there is no data hiding support at all, whereas; in the C++ language there is full support for the data hiding in the realm of the encapsulation.
- In C language there is only support for data types that are built in, whereas; in C++ language there is support for both the data types such as user-defined and built-in data types.
- In C programming language there are exactly about 32 keywords, whereas; in C++ programming languages there are exactly about 52 keywords.