Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

This question already has an answer here:

I only have programming experience with high-level languages, as well as with DBMS. Now, I would like to get into C and/or C++. My question is: Is the C language a pre-requisite in order to learn C++ effectively? I would prefer to concentrate myself in C++ and (later) learn C only if I really need it in real applications.

share|improve this question

marked as duplicate by gnat, BЈовић, Karl Bielefeldt, GlenH7, Rein Henrichs May 3 '13 at 5:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Has been asked a lot - answer is no –  Martin Beckett May 2 '13 at 20:10
I'd even go so far and say that knowing C is a detriment to learning C++. Modern C++ style has pretty much nothing to do with C. Learning Newspeak (for OO), Haskell (for Generic Programming) and whatever it is you learn to better understand templates (Prolog?) would be much more beneficial IMO. –  Jörg W Mittag May 2 '13 at 20:34
possible duplicate of Learning C, C++ and C# and of Is C++ suitable as a first language?. See also: How can I learn to write idiomatic C++? "I was taught C++ as a better version of C with classes. I end up trying to reinvent the wheel whenever a solution to a complex problem is needed, only to find sometime after that, some language feature or some standard library routine could potentially have done that for me..." –  gnat May 2 '13 at 21:03
Mr. Beckett is correct: C is not a prerequisite for learning C++. However, I disagree with Mr. Mittag: knowing C may be an advantage for learning C++, because there are many things about C++ that make no sense except in the context of being derived from C. Different strokes for different folks, I guess -- not everybody learns best in exactly the same way. –  comingstorm May 2 '13 at 21:16
@comingstorm - been programming C since before Ansi and I'm coming to the conclusion that C harms C++ skills. It's very difficult to not write for (int i.... and use lambdas or to call algorithms on collection instead of index arrays –  Martin Beckett May 3 '13 at 3:40

1 Answer 1

No way.

C is a brilliant language (and incidentally is far more lightweight than C++, if you ever need this), but it isn't object-oriented. Because of this, at the very start of a project, when you sit down and work out how you're going to work it, you'd likely come up with two different approaches depending on C or C++.

I would do the same as you - go for C++ straight off, with the caveat that you also couple it with a goal to understand o-o. The o-o bit is important, and for me is the real "win" - this is what would lead you to other languages such as C# and Java, both widely used commercially and incidentally, both cleaner than C++.

(You can of course use C++ in a totally a non-o-o program, but you ignore a lot of the features of the language if you take that approach.)

share|improve this answer
You can of course, also implement objects in C, like they have in the gtk+, but I'm just getting nitpicky. –  Philip May 2 '13 at 20:15
@Philip yes, I'm obviously generalising with what I say above. I suppose what I mean is that Kernigan and Ritchie never envisaged C as object oriented, while at the other end of the scale C# and Java were oo from Day One. C++ is something of a hybrid given its deep roots in C. But as you say, at this level of detail its semantics. –  PeteH May 2 '13 at 20:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.