You are here: Home &rarr Personal &rarr Differences Between C and C++

Differences Between C and C++

Although C++ is an improved version of C, there are a lot of differences in behavior and functionality between C and C++.

C-AND-C++

  1. C does not have any concept of classes or objects. It is procedure and function oriented. There is no concept of access through objects and a structure is the only data type where there is a access through a compacted variable. C++ is object oriented.
  2. C structures have a different behavior than C++ structures. Structures in C cannot contain functions.
  3. C i/o is based on library functions. C++ i/o is made through the cin and cout operators.
  4. C functions do not support function or operator overloading. In operator overloading, the same function has two or more behaviors based on their parameters.
  5. C does not support new or delete commands. The memory operations to free or allocate memory in c are carried out by functions like malloc() and free().
  6. Undeclared functions are not allowed in C++. The function needs to have a prototype before the main() before first use in C++ although in C, the functions can be declared after main(). There is no need for a prototype to be defined before main.
  7. For an int main() in C++ we need not write a return statement but the return is mandatory in C if we are using int main().
  8. In C++ identifiers are not allowed to contain two or more consecutive underscores in any position. C identifiers cannot start with two or more consecutive underscores, but may contain them in between words.
  9. C has a top-down approch whereas C++ has a bottom up approach while parsing.
  10. In C, a character constant is automatically elevated to an integer whereas in C++, this is not the case.
  11. In C declaring global variable is allowed several times but this is not allowed in C++.

Tags: ,


About Chinmoy


Chinmoy Kanjilal is the admin of this blog is a programmer and a technology, Linux and web2.0 enthusiast and evangelist from India with an eye for detail. He has a fondness for intriguing software products and hardware hacks.

blog comments powered by Disqus
Content on this Blog is Copyright © 2010 Techarraz. Some rights reserved.
Designed by Theme Junkie. Powered by WordPress.