I'd like to know main differences between C and C++,because they look similar.

C++ is based on C, and C is nearly a subset of C++ (nearly, because there are some incompatibilities, but mostly, these differences are technicalities). C++ has a lot more features than C:

  • Function and operator overloading (i.e., same name, different parameters).
  • "Object-oriented features", i.e., classes with different access right (private, public, protected), member functions, static members, inheritance, virtual functions (i.e., polymorphism), etc...
  • Namespaces, i.e., the ability to categorize code to avoid name-clashes between things with the same name in different libraries.
  • Const-correctness, i.e., the ability to make a promise not to modify a variable and propagating that promise.
  • Resource Acquisition Is Initialization (RAII) which uses non-trivial constructors and destructors to handle the allocation and deallocation of resources in a way that is automatically triggered leaving scopes (functions, objects, etc..).
  • Exceptions which are used to signal exceptional conditions (e.g., errors) in a channel that is parallel and "safe" compared to C-style error-code mechanisms.
  • Templates which allow for compile-time parametrization of code and data-types according to other types or compile-time constants. This allows for "Generic Programming" (GP) and "Template Meta-programming" (TMP), which are two central programming styles in C++.

The rest of the differences are most technical. And also, of course, the C++ standard library is a lot bigger (and well designed) than the C standard library (which is also included as a subset of the C++ standard library).

That just about sums it up.

It used to be said that C++ is C with classes. In fact, early C++ compilers would simply generate C code and then compile that. Before C++ was generally available, I used to write C code much like what C++ compilers would generate at that time. Honestly, I much prefer C++ to C now, and if I have to write C code, I still use C++ compilers, except for Linux kernel/driver code (for the most part).

C is a structured programming language but c++ is completely object oriented programming language.

Invadev

c++ is completely object oriented programming language.

No it isn't.

C++ USES THE CONCEPT OF OOPS-MEANS OBJECT ORIENTED PROGRAMMING THAT INCLUDES MANY NEW FEATURES LIKE POLYMORPHISM,INHERITANCE,CLASSES,FUNCTION OVERLOADING,AND IT USES A SPECIAL THING CALLED AS OBJECTS.
THERE IS NO MUCH DIFFERENCES IN THE THEORY PART EXCEPT THIS EXTRA FEATURES,HOWEVER C++ PROGRAMMING IS WITH SOME DIFFERENCES LIKE THE HEADER FILES OF C..STDIO.H IS HERE IOSTREAM.H. AND SCANF,PRINTF WITH CIN AND COUTS.
THE PROGRAMMING INCLUDES THE CLASS CONCEPT WHICH HELPS IN SPEED AS WELL AS USER CAN UNDERSTAND MORE CLEARLY.I THINK I HAVE GIVEN YOU SOME BASIC DIFFERENCE?!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.