Transition from c to c++ , difficulty.

Started by
13 comments, last by deathtrap 21 years, 1 month ago
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,
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++ versionprintf("Hello World\n");/* C version */ 


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

Beginner in Game Development?  Read here. And read here.

 

Thanks for the quick responce, much appreciated.

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.
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.
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
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
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.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
C++ rocks.
daerid@gmail.com
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.
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.

This topic is closed to new replies.

Advertisement