Difference between C and C++
What is C?
C is a structural or procedural programming language known for its machine independence and wide range of applications. It serves as the foundation for many modern technologies, from operating systems like Windows to complex software such as the Oracle database, Git, and even the Python interpreter.
Often regarded as a fundamental programming language, C is sometimes referred to as a "god's programming language" because it underpins the development of other languages. Mastery of C can make learning additional programming languages significantly easier. Developed by the esteemed computer scientist Dennis Ritchie at Bell Laboratories, C includes unique features that distinguish it from other programming languages.
What is C++
C++ is a specialized programming language created by Bjarne Stroustrup at Bell Labs around 1980. It builds upon the C language, maintaining a high degree of compatibility—C++ can execute 99% of C programs without requiring any changes to the source code. While C++ retains many features of C, it introduces object-oriented programming principles, making it a safer and more structured language.
Definition
C is a procedural programming language that does not include support for classes and objects. In contrast, C++ is an object-oriented programming language that incorporates the concepts of classes and objects.
Types of programming language
C supports procedural programming, where code is executed line by line. In contrast, C++ is an object-oriented programming language that introduces the concepts of classes and objects.
Developer of the language
Dennis Ritchie developed the C language at Bell Laboratories, while Bjarne Stroustrup developed the C++ language at Bell Labs around 1980.
keywords
C has 32 keywords, whereas C++ includes 52 keywords.
Exception Handling
C does not offer direct support for exception handling and relies on functions designed for this purpose. In contrast, C++ provides built-in support for exception handling through the use of try-catch blocks.
Input /output functions
In C, the `scanf` and `printf` functions are used for input and output operations, respectively. In C++, the `cin` and `cout` streams are used for input and output operations, respectively.
Inheritance
Inheritance is a feature that enables a child class to reuse the properties of a parent class. While C does not support inheritance, C++ does.
Memory allocation and de-allocation
C provides the `calloc()` and `malloc()` functions for memory allocation, and the `free()` function for memory deallocation. In C++, memory allocation is handled using the `new` operator, while deallocation is managed with the `delete` operator.