|
|
|
 |
Posted 2002-04-11, 08:37 AM
in reply to spa's post "Just a question..."
|
 |
 |
 |
Well yes, the most obvious difference is the OOP. In addition, C++ often requires an explicit cast (especially for pointers) where C does not. C++ allows you to declare variables anywhere in a function, whereas C requires all declarations to be at the top of the function. C++ has dynamic memory allocation with new and delete, which take object size and initialization into account, whereas in C, you have to use malloc and free, in which you have to specify a size in bytes, then cast it to the type you need. C++ allows function overloading, which allows you to replace pre-existing functions, and define several functions by the same name with different parameters or parameter types (so you could write an "int makeint(char*)" and an "int makeint(float)", and the compiler decides which one is best for your use of it), whereas C has none of this. C++ allows you to define operators, while C does not. There are a few other nit-picky things, such as use of constant variables in array size declarations, which I tend to forget, and are not terribly important.
So there you have it, an overview of the differences between C and C++
--WetWired


|
 |
 |
 |
|
|
|
|
|
|
|