Differences in C and C++ language

So, as I previously mentioned, I wasn't very sure that I would be able to upload a blog everyday, I missed to do that yesterday, as I got indulged in reading an ecstatic novel by the well known author Preeti Shenoy, that is "Life Is What You Make It"

C++ which came out in 1985, 13 years after the C language was an advanced version of it, most of the problems which the developers faced with the C language were tried to jettison away. Some of the differences which I recently came across while my perusal of the C++ documentation of the GFG website were related to the differences between the structures of both the languages, and how both the languages treat character literals differently. 

Character literals in C lang. are considered of Int datatype, which is quite uncanny, whereas in C++ they are considered of char datatype only which is logical. Other than this, if you will use the comparison operator(==) in C for two equal elements, then surprisingly the compiler returns integer datatype value, which is unusual cause it should return a boolean value which it does, but in C++, not in C.

Talking about Structures, being one of the important parts of both these languages, most of you must be familiar about what these are. As I remember, a structure is a user defined datatype that can contain values of different datatypes into a single type. So, some of the differences that I recently got to know are:-

1) In C we cannot create member methods, we can only create data members.

2) In C data hiding is not possible.

3) In C we cannot directly initialize data members.

4) In C we cannot create constructors.

5) In C we do not have access modifiers.

6) In C we have to compulsorily use the keyword "struct" while declaring a variable of the structure.

While in C++ we do have all these features. This is a small part of the difference between these languages, by this we can surely get an idea about what type of changes were made to make things easier for the developers.


Comments

Popular Posts