This might have been correct 10 years ago, but now C++ has completely different style to C. You can code in C if you use C++, but you cannot code in C++ if you use C. C++ is just different paradigm of thinking with classes (and everything that goes with that), objects, STL (if you don't use STL you are not programming in C++), etc
As one person on the Internet said:
"Put simply, what is considered idiomatic in C is definitely not idiomatic in C++.
C and C++ are very different languages in practice, because of the way people use them. C aims at minimalism, where C++ is a very complex language, with a lot of features."
Actually, this is only semi-true... If you attempt to write C++, coming from a C background, you'll probably end up just using pointers where references and/or iterators would be better suited paired with some kind of container. You may be frustrated by things like sizeof('x') in C vs. sizeof('x') in C++, but those are still quite minimal issues. If you use a function in C++ like malloc() and you're used to not casting the return, a compiler error should guide you in the right path pretty quickly. Just because the standard idea of C++ typically requires a different way of thinking, doesn't mean you can't write C-like code in C++. You probably just won't be using half of the features available to the language is all.
So I assume you mean to say that "you can't write REAL C++ code coming from a C background," just to clear the confusion, and if that's the case, then you are 100% correct.
Because it's bad to mix the two... If you use C I/O instead of C++ I/O when programming in C++, you're probably not taking advantage of RAII as you should for instance with things like std::?fstream.
There was a comparison I read recently.
"
Using C is like walking on one side of the road and possibly getting hit by cars in one direction, using C++ is like walking on the other side of the road and getting hit by cars going in the opposite direction, but using C & C++ is like walking down the middle of the road and getting hit by cars going in both directions."
Hi s3my0n,
Although you are absolutely correct in in what you said I'm afraid you misinterpreted what I meant. Taking in consideration that the OP has no programming experience the first programs are going to be very minimalistic and simple in nature. Does it really matter then if you use C or C++ when you at highest write a function or two to learn the basics?
There is an argument to be made for C++'s STL and that the books mentioned by him all use C++ as a basis, but for the purpose of learning C/C++ I really don't think it matters a whole lot how you start out because it will be in roughly the same way and you'll still end up using the rich C++ environment in the end.
Maybe it doesn't matter, but as I said, you can still run into discrepancies without delving into the STL for the comparison of C and C++. These languages are even less comparable now as the years go by... If you happen to run into one of the small but subtle differences, it may be confusing to the person trying to learn the language.
If you have an idea of what kinds of things you want to do with C/C++, then you should try to choose THE language of the two that best suits your goals, and stick with it. If at a later time you decide you want to learn the other, then do so... There are cases where C++ is more suitable than C and others where C is a better option than C++.
If you plan on learning C++ then, as s3my0n is trying to explain to you... You
should NOT be trying to write C-like code in C++, just because it compiles fine. The STL is provided for a reason, and a good one at that. You don't have the STL in C, so if you're learning C++ or not, you're either using it or not using it; C or C++.
Killordie, there's a big difference between even the hello world versions of C and C++; printf() and std::cout are not even remotely the same, just because they can be used to write output to the console's stdout.