Menu
Jan 13, 2011 C and C are both programming languages. C is a procedural programming language whereas C is an object oriented programming language. There were certain drawbacks in the C language. That is why, C was developed.
The major difference between C and C++ is that C is a procedural programming language and does not support classes and objects, while C++ is a combination of both procedural and object oriented programming language; therefore C++ can be called a hybrid language. The following table presents differences between C and C++ in detail.
Difference Between C++ And C
C | C++ |
---|---|
C was developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. | C++ was developed by Bjarne Stroustrup in 1979 with C++'s predecessor 'C with Classes'. |
When compared to C++, C is a subset of C++. | C++ is a superset of C. C++ can run most of C code while C cannot run C++ code. |
C supports procedural programming paradigm for code development. | C++ supports both procedural and object oriented programming paradigms; therefore C++ is also called a hybrid language. |
C does not support object oriented programming; therefore it has no support for polymorphism, encapsulation, and inheritance. | Being an object oriented programming language C++ supports polymorphism, encapsulation, and inheritance. |
In C (because it is a procedural programming language), data and functions are separate and free entities. | In C++ (when it is used as object oriented programming language), data and functions are encapsulated together in form of an object. For creating objects class provides a blueprint of structure of the object. |
In C, data are free entities and can be manipulated by outside code. This is because C does not support information hiding. | In C++, Encapsulation hides the data to ensure that data structures and operators are used as intended. |
C, being a procedural programming, it is a function driven language. | While, C++, being an object oriented programming, it is an object driven language. |
C does not support function and operator overloading. | C++ supports both function and operator overloading. |
C does not allow functions to be defined inside structures. | In C++, functions can be used inside a structure. |
C does not have namespace feature. | C++ uses NAMESPACE which avoid name collisions. A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries. All identifiers at namespace scope are visible to one another without qualification. Identifiers outside the namespace can access the members by using the fully qualified name for each identifier. |
C uses functions for input/output. For example scanf and printf . | C++ uses objects for input output. For example cin and cout . |
C does not support reference variables. | C++ supports reference variables. |
C has no support for virtual and friend functions. | C++ supports virtual and friend functions. |
C provides malloc() and calloc() functions for dynamic memory allocation, and free() for memory de-allocation. | C++ provides new operator for memory allocation and delete operator for memory de-allocation. |
C does not provide direct support for error handling (also called exception handling) | C++ provides support for exception handling. Exceptions are used for 'hard' errors that make the code incorrect. |
Hope you have enjoyed reading differences between C and C++. This comparison of C and C++ explains feature-wise difference between both programming languages. Please do write us if you have any suggestion/comment or come across any error on this page. Thanks for reading!
References
- Kernighan and Ritchie, The C Programming Language, 2nd Ed.
- C: The Complete Reference
- Randal E. Bryant, David R. O'Hallaron, Computer Systems: A Programmer's Perspective.
C And C++ Comparison
Mar 23, 2020 C supports built-in data types whereas C supports built-in as well as user-defined data types. C language follows the Top-Down programming approach whereas C follows a bottom-up programming approach. Dec 28, 2017 difference between c and c in hindi. Difference between int main and void main - Duration: 2:54. E Tech Learnings 86,021 views. Corejava-Basics-Difference b/w C. Aug 11, 2011 The difference is that Dev C uses the MINGW compiler, where Turbo C uses Borland's compiler. Which means that not all of the functions used with Turbo C will work with Dev C compiler,while the opposite is true,bcoz the Dev C uses the standard compiler for the C.
Difference Between And In C
Key differences between C and C#. Both are popular choices in the market; let us discuss some of the major difference: C is not a pure object-oriented programming language whereas C# is a pure object-oriented programming language. C doesn’t support bound checking for arrays whereas C# supports bound checking of arrays. Nov 13, 2011 What is the difference between C and C#?. C# is an object oriented programming language, while C is a structural language. C can access low level OS functions making it better in performance compared to C#. C# is a ‘managed’ language, which means that code compiles to an intermediate form that then runs on a virtual machine.