C vs C++
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 C language
C is a computer programming language developed in 1972 at Bell Labs. It was mainly designed to be used with the UNIX operating system. Apart from developing system software, C language is also used to develop portable application software. Structural programming is provided by the C language and it allows recursion as well as lexical variable scope. Unintended operations are prevented by static type system.
Functions contain all the executable code on the C language and the parameters of the functions are passed by value. Pointer values are used when functions parameters are passed by reference. To terminate a statement, semicolon is used.
Following are the characteristics of the C language:
• Ad-hoc run time polymorphism is supported by data and function pointers.
• Reserved keywords are small.
• A wide variety of compound operators such as ++, -=, += etc.
• Conditional compilation, file inclusion of source code and a macro definition preprocessor.
A set of functions are used in C language. Each program in C language is executed in a function called “main function.”
C++ is also a computer programming language. C++ is a high level and object oriented language. C++ is the most commonly used among all programming languages. C++ was developed at Bell Laboratories and it termed as the enhanced version of C language. The features of C++ language include templates, classes, operator overloading and virtual functions. Exception handling and multiple inheritances were also introduced in C++. As compared the C language, more type checking is available in C++.
As it is considered as the enhanced version of C language, most of the features of C language are maintained in C++. Even the C++ compilers are able to run programs created in C. However, some code written in C may be incompatible with C++ compilers.
C++ was originally developed for UNIX system. The code written in C++ is reusable which means that modification can be done in the code without changing it. C++ is portable also which means it is independent of operating system or it does not require specific hardware.
Class is another important feature introduced in C++. The code can be organized with the help of classes. By using classes, bugs can be removed as well as corrected easily.
|Difference between C and C++
• C is a procedural programming language whereas C++ is an object oriented programming language.
• C++ introduced the concept of polymorphism, inheritance overloading whereas these are not present in C language.
• Object oriented approach such as objects and classes is used in C++ language.
• Although most of the C programs can be compiled using C++ compilers but still some programs may be incompatible.