Sign in to follow this  

How different is C from C++ ?

This topic is 4092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I have been eye balling that book called Beginning Game Programming by J.S. Harbour and he says that you will need to know the basics of C. I already have Beginning C++ Game Programming by Michael Dawson and I have been reading it for a while taking my time and moving along little at a time grasping everything with a firm grip over the understanding of some of the more uterly complicated things. I also want to buy this other book because it does everything not just a language, so can I jump into it with basic knowledge of C++ or not? please explain how different are the two languages?

Share this post


Link to post
Share on other sites
The differences between C and C++ are usually minor. If you are familiar with classes in C++ then you'll notice that they're missing. new and delete are replaced with malloc() and free().

In short, you'll be fine.

Share this post


Link to post
Share on other sites
Hmm, lets see..

new/delete -> malloc/free
templates -> macros
std::vector -> void*
std::string -> char*
functors -> function pointers
classes -> POD structs
member functions -> global functions
namespaces -> name prefixes
iterators -> pointers
inheritance -> ?
polymorphism -> ?
metaprogramming -> ?

Other than that C++ and C are pretty much the same.

[Edited by - deathkrush on October 1, 2006 1:49:26 AM]

Share this post


Link to post
Share on other sites
templates → a small subset of the functionality can be performed by macros. A large amount of other details (specialization, ease of debugging, ...) have to be handled in other, more imaginative ways.

std::vector → T[], for any type. If you wish to use dynamic arrays, T*, preferably as part of an opaque type.

functors → closures (void* data and function pointer)

classes → opaque types

member functions → global functions operating on opaque types

destructors → one delete per base object type, which calls the embedded destructor and releases the memory, or use objects that do not require destructors.

inheritance → opaque type parametric initializers

polymorphism → opaque types with member functions

metaprogramming → external metaprogramming language/code generator

T& → T*

const T x = y; → #define x y

Share this post


Link to post
Share on other sites
Ok, I'm not really swtiching I just have a desire to buy this book since it covers the basics of everthing. So I can keep learning C++ and buy this book and I'll be good?

Share this post


Link to post
Share on other sites
Yes. They're different languages (despite the popular misconception that C++ is a sort of "C with extras") and are programmed in different styles, but if you understand the basics of C++ you shouldn't have any major difficulties with a book that requires a basic understanding of C. Just keep in mind that the thought process may be somewhat different at times, look up anything you don't understand and you should be fine with it.

It would actually be quite a good way to test and solidify your understanding to convert the concepts taught into a more C++ way of thinking as you go if you feel up to it.

Share this post


Link to post
Share on other sites

This topic is 4092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this