Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

deathtrap

Transition from c to c++ , difficulty.

This topic is 5589 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

Good day, For those of you who have learned or worked with both languages, how easy of a transition is it to go from working with c to c++? Should I continue to learn C or should I drop it and concentrate on C++ ? Thanks,

Share this post


Link to post
Share on other sites
Advertisement
IMO the transition isn''t that hard.
you''ll have to learn for example:
to print something on the screen you''ll have to use

cout << "Hello World" << endl; // C++ version

printf("Hello World\n");/* C version */


little things like that.
to know both is a benefit to yourself.

Share this post


Link to post
Share on other sites
Going from C to C++ is 1000% more complicated than learning to use cout instead of printf ! That''s the very tip of the iceberg ! It''s not just about learning new syntax, it''s learning the concepts of the language which really are quite different from C. The best way I found to transition was to read lots of programming books, each one explains each concept in a slightly different way and overall that helps you to understand better.

Share this post


Link to post
Share on other sites
You *only* need to learn the principles of OO in order to move to C++.

Personally all I (and most other programmers I know) take from C++ is the OO approach. Once you know how to work with objects you can still use C syntax within them. Apart from swapping malloc for new and free for delete using C syntax within C++ is perfectly valid.

I for one see very little point in using c++ commands such as cout etc when printf, fopen etc work perfectly well.

Share this post


Link to post
Share on other sites
The reason C++ programmers use cout is because you can do something like this:

cout << myObject; 


and it will print out the state of myObject any way you want. This is impossible with printf, etc., since you can''t define your own insertion operators for use with those functions.

Firebird Entertainment

Share this post


Link to post
Share on other sites
Transitioning to C++ from C can be difficult, likely in part due to the fact that C++ tries to introduce concepts to the C language which it wasn''t inherently designed for, both in terms of purpose and structure.

By extending C to C++, it seems the designers handicapped themselves with a paradigm not suited for the concepts which C++ tries to provide, thus making the realization of C++ a complicated product that doesn''t have an elegant or streamlined paradigm.

Share this post


Link to post
Share on other sites
Full c++ is very hard to learn and put to practice. Using a subset of c++ is pretty doable. If you''re doing strict gfx stuff then the choice of the lang. is even less important. If you''re doing data management app then c++ will be more handy. I''m into gfx at the moment and all you need is ''c'' from within ''c++''. I''m spending much more time doing maths and geometry related stuff then strictly programming lang. related stuff. Getting the hang of gfx api and hw is not easy, the least you need is to fight the language at the same time.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I suggest you stick with C for now until you are very comfortable with it. And then pick up "C++ Primer" (Lippman) and "The C++ Standard Library" (Josuttis), forget everything you know about C, and concentrate on the new style of programming. You will benefit from thoroughly knowing both languages. Plus, all too often, people using C++ are only using C with some limited C++ functionality, like classes, etc. Learning both will help you greatly.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!