10 Major Differences Between C And C++
C++, as the name suggests is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C...
1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented)
In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process.
Also, it is easier to implement/edit the code in case of C++ for the same reason.
2. In case of C, the data is not secured while the data is secured(hidden) in C++
This difference is due to specific OOP features like Data Hiding which are not present in C.
3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post)
C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language.
4. C uses the top-down approach while C++ uses the bottom-up approach
In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems.
5. C is function-driven while C++ is object-driven
Functions are the building blocks of a C program while objects are building blocks of a C++ program.
6. C++ supports function overloading while C does not
Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature)
7. We can use functions inside structures in C++ but not in C.
In case of C++, functions can be used inside a structure while structures cannot contain functions in C.
8. The NAMESPACE feature in C++ is absent in case of C
C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)
9. The standard input & output functions differ in the two languages
C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions
10. C++ allows the use of reference variables while C does not
Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.
Don't forget to check out :
MORE -
11. C++ supports Exception Handling while C does not.
C does not support it "formally" but it can always be implemented by other methods. Though you don't have the framework to throw & catch exceptions as in C++.
(will add more..)
UPDATES (ref to comments)-
Praveen - some of them r telling ‘C’ is a middle level language…..tell me the correct type of level language….?
Answer-@praveen – I agree there are always mixed opinions about this one. Some even like to call it a high-level language. But there’s really no determining factor behind the level of a programming language. Essentially, we’re making all the changes at the machine level, right? Now, as we increase the abstraction and move away from the machine-level, the level of the language increases. So, the level is nothing but the level of abstraction. So, most of the languages we use in applications today will have aspects of both machine-level and user-level. The two levels are machine-level & user(real world)-level while high & low levels are relative terms. Although, C is on a lower level of abstraction “relatively”- when compared to C++. Hence, referred to here as low-level.
Mitchell -
cin and cout are part of the std namespace, and they’re not functions. They’re almost like “pipes” in a sense. What you’re doing is essentially bit shifting (<> are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.
thanks! just what i was looking for..
hey i never got the namespace thing.. I haven't coded much so ive never used it apart from our usual "using namespace std" Where else can it be used? As it says in the post it avoids name collisions. how is that?
Ronnie :: You can even create your own namespaces and do a lot of stuff with it..
Check out the post More On Namespaces to find out how to do the same.
gud this is wat im searching actually……….thanks………………..
Anu :: Thanks for reading!
Well compiled!
Bilesh :: Thanks Man!
thanks
sir,
becouse today i undusstand the actual difference between c & c++
Thank you very much for this brief n imp notes
thanks for providing the valueble information
c is middle level language while c++ is a high level language
which 1 uses top down..nd bottom up approach..nd why...
great job....................
thanks.
excellent,this is what i m searching...........................thanks
well scheduled data packages.............!!! i was lukin for that.....
iam looking for detailed description of c++ language..... wer is it ??? pls include dat...!!!
thanks a lot! very useful ones/.
thans for good explanation.
@saurabh kushwah - see the 4th difference..
thanx sir for good information....
Hey Jacks.. I just started adding complete C++ tutorials. You can start here - http://zarrata.com/durofy/computers/programming/c-tutorial-1-the-basics/
thanks, for giving such a good kind of information.
i realy impressed with that answers..
thanks for giving valuable information....
Thanks alot
this is wt i want 2 search thanks
Thanks a lot for providing such information keep it up
dude its really helpful.>...>>
Exellent information..
Thank u sooo much...
Expecting more....
@bhuvana
thank you
thankyou for helping me like this, because of you i have learnt the difference between c and c++.
thank u sir, i'm understood what you are said.
thanks......
my search completed
sathiya :: i like that
Really Awesome ... Thanks a lot boss u made my engineering worth ...At last i came to know the basic difference between these two...........................thanks
@Amit
Thanks for commenting.. Makes me feel good :)
Thanks for your cooperation for providing me such a great help coz 2morrow is my exam n i need it n i got it..........
Thanking you.
thank you for providing every one of us with such differences btw c and c++...
thanks a lot man.....very informative ...
thank you ....dis is really very helpful ,as all the differences have been explained with clarity,and covers all the important aspect.........
Thanks for reading Saurabh :)
some of them r telling 'C' is a middle level language.....tell me the correct type of level language....
@praveen - I agree there are always mixed opinions about this one. Some even like to call it a high-level language. But there's really no determining factor behind the level of a programming language. Essentially, we're making all the changes at the machine level, right? Now, as we increase the abstraction and move away from the machine-level, the level of the language increases. So, the level is nothing but the level of abstraction. So, most of the languages we use in applications today will have aspects of both machine-level and user-level. The two levels are machine-level & user(real world)-level while high & low levels are relative terms. Although, C is on a lower level of abstraction "relatively"- when compared to C++. Hence, referred to here as low-level.
verry nice.... thanks a lot
thanq, it was very helpful........
Thanks a lot Sir!!!
Its really a very basic thing in software empire.
One can not point out such smaller but major differences.
You gave us it as ready made.
Thanks a lot once again!!!
this is realy good one and stick to something i want...thanks for the same...
its really a very gud differences... it will help the students a lot.. so thanx a lot for helping students....:-)
gud... keep it up..
thank u for providin those details..
it's good..
expectin more.....
Thank you very much..... This is the greatest answer i ever seen.....
Thanks for helping complete my assignment.
ans is vry helpful
@prabhu Thanks a lot! :)
thank u so much......for the information..
Not a complete list. A couple of other differences:
C allows void* to be assigned to another type with no warnings.
C requires the struct keyword when defining a variable of a struct type. C++ automatically "typedefs" structs.
C has no operator overloading.
You can omit the return in main() in C.
There are some others, but it's been a while since I used C.
@Howard - It isn't meant to be complete.. :)
Just thought of another. Actually, this is a side-effect of not having classes, but dynamic allocation in C uses only malloc() and free(), since there is no concept of a constructor or destructor.
thanks it's very helpful :D
Thank you very much...Exelent answer
thnx for ur sharing
thanx a lot... a well defined and an easier one!!!!
I will add possibilities of C++: inheritance and events
but (10) I think language C suport reference variables
please send us a code to show how c is top down and c++ is bottom up approach v'l b waitin
Thanks Dude......................Nice information
thanks for ur kind information
Thank u soooooooooooo much! 10 points are enough for my home work :P
different between c$c++
nice things i got
@annu
nice things i got
@annu
@deepa
good.........
thanq very much for ur anwers
Thanq sooo much for ur valuable information :-)
thanks for sharing.......but its enough for master level????????????????
Very good my friend...
There is one more difference that C don't have ++ like C++....
Joking man
thanks for this valuablr information
he, thanks 4 helping us.....we would b ever thankful 2 u. once again .....THANKS
nice
thanks for information
now i have cleared my doubt.
Notes are very helpful for self study and extra knowledge.I will thanks to giver and internet.
My village is Himayoupur (G.B.Nagar). But at this time i am living in ghaziabad finally i will say notes are very helpful for self study and extra knowledge about everything.So for this facility i will thanks to internet service provider and notes provider.
can u tell me which was the first version/compiler of c++....urgent!!!!!!!!!!!!!!!!!!!!!
good points i got and one more suggestion is....
c support 32 key words and c++ support 42 key words
nice....it's very useful for me...
how can we explain top down n boottom up approaches in n c++...
thanks ..................its very useful for me
THANKS FOR THE INFO.. IT REALLY HELPED.
Point number 3 is totally wrong bcz c is middle level language and c++ is high level language.
so plz correct it.
You probably dint read the complete post. Please see the discussion at the end of the differences.
thanks a lot u help me very much.
what is the major difference between C,C++ &java?
thanks a lot am clear now and its very useful
its very useful and this is wat i was looking for
very thanks for information good
can u send some programs such as, factorial,prime no,fibonaci
and can u shortly explain about pointer?
Check out the post
>> http://zarrata.com/durofy/programming/an-introduction-to-pointers-in-c-programming/
thanks for sharing......
Thanks.......... a lot
C++ have exception handling where as c dont have!!!
thanks for the info...... got more than my book...... :)
Great! Moreover, you don't want to read the complete C & C++ text to get such a simple answer ;)
Don't know why i forgot that. Have added it as the 11th difference. Thanks!
thanx 4 d info......helpful 4 my assignment
I confuse in top down app & bottom up app..................
Thanks...........
thanks dude.......!!!!
Thanks bro.. good answer.
thanks dude…….!!!!
Good Answer. Brother
Thankz for the information.
This is enough for my computer science assignment
thanks and keep updating the information it will be useful for the students like us
THANKS BRO ,
VERY GOOD ans
thanx for help.....
keep it up boss
Thank you for the comments! :)
C is not a client server model while C++ is a client server model. C++ can solve the real world problems while C can't. These are also the differences.
it was good....never could read this any one of the books of c or c++..thanks a lot..
You can use functions inside of structs in C via pointers, but I supposed that's not what you really mean, it just sounds slightly misleading to me.
Also, cin and cout are part of the std namespace, and they're not functions. They're almost like "pipes" in a sense. What you're doing is essentially bit shifting (<> are bit shift operators) data into and out of them. As well, C++ still supports use of printf and scanf, so your std.cin and std.cout are by no means exclusive in their duties.
All in all a good article, just a couple nitpicks.
Thenxxxx alot for the basic informations..........
lost my interview just bcoz of this ques....
really given in a lucid way........is extremely easy to comprehend
@Mitchell - Thank you for pointing it out. Will add an update to the post. :)
Thank You Mayank :)
thanks for giving the basic concepts
Thank you for reading :)
THANKS FOR MORE INFO I USE IN MY EXAME
thnaks dude it's found very help ful for me....once again thanks
Thanx a lot ,,,,,,,
This can be effective in my Campus....
thanks a lot for this information
@Harsh;Himanshu;Gulshan;Naveena - Thanks for the comments! :)
i dnt understdd top down & bottom up approach so plzzz help me sir...
Wait so can I learn C first and then move on to C++... will that work? Because I have started watching video tutorials about C and I am learning a lot but will I be able to do those things in C++?
Please reply!
Thanks
That's the only way it works. I hate to call C a "programming language". It is more like a "programming prerequisite". C is to programming what Algebra is to Calculus.
thanx dude i got 10 marks in exam
thank u very much 4 this information.........
thanx
txs it really help full for me......
nice and helpfull
poda panni parathesi naiye un inforamtion na neeye vatchuko da lusu pu............
thks very much
thanx to provide me imp knowledge
Pls give me aprogram which can be compiled in c and does not compiled in c++??????
its too favour 2 me........
Thnx! Coming from Java, now I know it's C++ I should learn. =)
12.Main doesn't Provide return 0 Automatically in c,but in c++ it is..
13.No Boolean type in C,but it is present in c++
14.We must declare functions before use in c++,but c does't require it.
15.presence of keyword 'new' instead malloc in c
really really helpful..thnx..:)
Thanks for information rishab,it's really working out.......
Hey! You got a nice blog :)
Thank You :)
THANKS SIR! I HAVE GAIN A GREAT KNOWLEDGE AFTER STUDY UR SITE, ABOUT THE C**AND C DIFF......
GOOD JOB
Thanks for better E-Information tanks to all of u who make it...........Mayank
what is the differnce between c++ and other structured languages?
plz
do reply...
thank you!
thanks for ur good info
Really very helpful,.,.,
thanks a lot for this information........
Thanks. for special points , I am very satisfied by these 10 points and these are very help full for me
Thanx......boss.. this difference is very easy to store on my mind, its never forget to me.. short answers nice keep it up boss... and also keep this typ of answers always it will help full for students..like me
Thax...........
thanks for this informative post. It helps me a lot to understand some differences both in c and c++.
@kajol
can u give some example for it? how cpp is having client server model?
tNx a LoT fOr pErfeCt inFOrmAtiOn
thanq so much........ :-)
useful information.. thanks
tnx a lot 4 in4mtion................................
Thanks a ton!!
Hehhh can yu please provide me the complete information with explanation on the main OOPS principles..please ya
And the above information is perfct..thank yu ya..
http://www.durofy.com/programming/the-basics-of-object-oriented-programming/
thannxxx a lot... its really useful...
nice!!!!!!!!!!
vry usefullllllllll!!!!!!!!!!!
What are the things are not possible in c when cOmpaRed to c. Pls tell me..
Why the c++ is better than c??
very good info.
Nicely written.....
really useful !!!!!!! i'l use in my assignment , preparing today...... :)
ITs very helpful for uplift my Programming Language MY own thank u for this usual info