Thursday, July 30, 2009

What is the difference between c language,c and c++?

please give info. in detail or provide a link.


what are the functions of these three?


is learning one of these required for another one?


i want to take c courses for 11th standard in south mumbai.any suggestions?

What is the difference between c language,c and c++?
C is older and more lower-level than C++. This mostly comes into play when doing memory allocation. For example in C I would do this:





int* array = (int*)malloc(sizeof(int)*10);





And in C++ I would do this:





int* array = new int[10];





Another huge difference is that C doesn't have classes, whereas C++ does. One of the most annoying times this comes into play is when working with strings. In C is you want a smaller part of a string (a substring) you need to dynamically copy it out, but in C++ you just call string.substr().





You can learn one without the other. If you're relatively new to programming, I would start with C++ because it's a little easier and is probably more similar to any other language you have encountered.





I've posted a couple of links highlighting the differences also.
Reply:dear god if your going to answer a question please show some literacy...





C and C++...I dont know the huge difference partly because I use Java and other various languages...but I think its like comparing JavaScript to actual Java....two complete differences and I would imagine a difference in speed too
Reply:c IS c language, c++ is an object oriented version of c, it is a super-set of c. c has been around at least since the early 70s, c++ has been around since the late eighties. It probably does not make a difference which one you learn first although I would suggest c++ which contains all the features of c. vc++ is Microsoft's version of c++, it is graphically oriented like visual basic.
Reply:language,and++
Reply:u mujst refer dis site its gud for c and c++





www.cprogramming.com





and





cplus.about.com/
Reply:c++ language is a advanced than c languages
Reply:I would agree with sfpiano's comments, but would not agree with his conclusion.





First off, it is important to understand that c++ _IS_ c, but with extensions.





c++ and c are basically the same language, but c++ has additional features and abilities and extensions.





Without fully understanding the programming language that lies underneath BOTH languages, you can't program very easily in either of them.





c++ adds a LOT of functionality to c, and it does so with the understanding that the programmer understands c.





Before you can, say, declare a class that inherits from another class, and do so effectively, it's a really good idea to be able to define, say, a simple structure that does what you want it to do.





My advice would be to get comfortable with c before moving on to the extensions offered by c++. Once you know c, you can learn the extensions of c++ in a relatively short time.





I've written probably 200k+ lines of c source and 150k+ lines of c++ source.





When I code in c++, my code is more elegant and refined, but I would not have been able to reach that level of elegance if I didn't know how to do, oh, pointer arithmetic and stream manipulation.





When I say, "Get comfortable with c" I don't mean "just write in c with no c++ extensions."





Use the new operator instead of calling malloc().. That's a great idea.


Get used to declaring functions that take references instead of pointers.


But you're not even going to begin to understand my advice until you know enough about c to know what it means.





So learn c to learn what it's about, while all the time peeking at the stuff c++ can do, and implementing it once you understand it.





I hope this helps.


No comments:

Post a Comment