Quote:
|
Originally Posted by grumpy
The difficulty in transitioning from C to C++ depends on whether you want to treat C++ as an "extended C" (for want of a better description) or if you want to use C++ as it is intended.
Treating C++ as an extended C essentially means continuing to use the C language and library, but making use of features of C++ like better typechecking (the underpinning of why a C++ compiler will find errors that a C compiler won't in C code), function overloading, default argument values, using operator new/delete as an enhanced malloc()/free(), and (if you want to push things a little) starting to use classes to define new types and maybe using templates in some basic way. If all you want to do is this, then moving from C to C++ is fairly simple.
Using C++ as it is intended means a paradigm shift (and OO is only part of it; C++ is a multi-paradigm language). If you go down this route, you will be more rigorous about encapsulating data into classes, using C++ rather than C I/O, using the STL, and using advanced features of templates (the template mechanism within C++ is a Turing complete programming language in it's own right), make use of exceptions, etc etc. All of these areas take time to learn and (in fact) learning to use them well is probably a life-long endeavour. Not even experts like Bjarne Stroustrup, Scott Meyers, Herb Sutter, Robert Martin, or Andrei Alexandrescu claim to be complete masters of C++.
Most people who move from C to C++ initially treat C++ as an extended C. So, for most people, the transition is not that tough. Late on, however, a fair few people learn that there is a lot more to C++ and that takes longer.
BTW: I disagree with nnxion's characterisation of C++ as a big language and C as not. I would characterise C as a large and complex language on it's own. C++ is just larger and more complex than C.
|
Hmm yeah I use C++ as an extended C, also because I haven't done any large (more than 10 thousand lines, which is probably medium-sized for you

) projects in C++.
Well there is a difference between "small" and "not big". Even Kernighan and Ritchie say on the back of their book: "We have tried to retain the brevity of the first edition. C is not a big language, and it is not well served by a big book."
Your points on C++ are excellent, I'm glad you are there to educate us (read: me).
On a side note: I took the liberty of talking about projects like lines of code were the only indication of how large projects are.