Tuesday, March 6, 2012

advantages of c++ over c language

advantages of c++ over c language:
It is good to have development using C, but not always.  In the real world you will notice that the code written in C++ has some advantages over C. We will see some of the advantages and with some example that I will present in coming tutorials wherever applicable. But before reading all those honestly as a programmer you should respect both language and most of the things depends upon how you are going to use them.
1.       Native support for object oriented programming which provides
a.       Data and methods to edit data act as one entity(using classes)
b.      Limiting scope of data (using private public variables)
c.       Constructors and destructors for defining default behaviour of entities(objects)
d.      Can add your own handlers that intercept and hide message handlers for existing classes.
2.       Richer standard library.
3.       Type safety of C++
4.       No support for generic programming.
5.       RAII (Resource Acquisition Is Initialization) feature to deal with resource deallocation. the only code that can be guaranteed to be executed after an exception is thrown are the destructors of objects residing on the stack.
6.       Best suited for distributed system programming.
7.       The design space in C++ is much richer than in C. C is a fairly simple language. All it really offers is macros, pointers, structs, arrays, and functions. No matter what the problem is, the solution will always boil down to macros, pointers, structs, arrays, and functions. Not so in C++. The macros, pointers, structs, arrays and functions are still there, of course, but so are private and protected members, function overloading, default parameters, constructors and destructors, user-defined operators, inline functions, references, friends, templates, exceptions, namespaces, and more.

No comments:

Post a Comment