Thursday, July 30, 2009

I want to learn C++?

I know basic, html and a little javascript, but I need to know C++ too.





Do I need to learn C first to be able to learn C++?





I would like to learn it online. Can anyone suggest a good site that takes you through it step by step?

I want to learn C++?
Personally, I learned C++ and object-oriented programming after I learned C.





C is a subset of C++, so this way I was able to make a living writing working C programs for a few years, before having to learn additional concepts (OOP) and additional language constructs (virtual functions, pure virtual functions, static methods, constructors, destructors, virtual destructors, const, class declaration, etc.)





The downside is, knowing those object-oriented programming techniques would have allowed me to design simpler, smaller programs. I could have built them in stages, rather than kind of all at once.





They would have fallen naturally into better organized modules too. When writing in C, I would have to think which functions to put in which .c file. When writing in C++, you put more or all of your code in objects. By convention, each class has its own .cpp file - so the decision of which file to put each function in is kind of made for you. And, that winds up making it easier to find each function too!





Outputting strings and numbers from a C++ program is much easier and far less error-prone than it is in C too. That will make your life easier right from the beginning.





So today, I would say you are better off learning C++ and kind of ignoring C. Do not feel like you have to learn the whole language at once. Take it slow.





You will be heartened to know many of the statements of both languages - especially the control structures - are the same: for, while, do, break, continue, if-else, and goto.





Learn one piece at a time.





Avoid using pieces of the language in a real program before you have studied up on that piece, learned the DOs/DON'Ts of it, and used it. If you try to do several new things at once, it can get very hard to figure out what mistake where caused something to go wrong. You wind up staring at an error, and not knowing where the program the fault lies.





To make an analogy, think about algebra. It is kind of easy to solve an equation where you only have one variable you do not know the value of. It is kind of hard to solve an equation where you do not know the values of two or three of the variables!





I have listed the URL of a pretty good C++ tutorial in the Sources section of this answer. Hope this helps!





By the way, after learning C and C++, I went on to learn to use Java. Java seems simpler than C++ and Java programs seem to have fewer errors in them the first time you run them to try them out. Java programming tools have overtaken C/C++ programming tools.





You may be required to learn C++ now, in which case this advice to consider Java will not help you. However, if you have a choice, try to find out if Java might be a better language for you than C++.
Reply:It would be helpful to learn the basics of C programming first, before you start learning C++, but its not absolutely necessary.





The following are some good free tutorial and books that will get you going on learning C++:





Thinking in C: Foundations for Java and C++:


http://personales.unican.es/corcuerp/Thi...





This blog post of mine contains links to 23 C and C++ Programming Ebooks and Tutorials:


http://www.intelligentedu.com/blogs/post...





Here are C++ learning materials from only4gurus.net that will help you:


http://www.only4gurus.net/miscellaneous/...


http://www.only4gurus.net/miscellaneous/...


http://www.only4gurus.net/miscellaneous/...





Here are lecture slides from a class on Object-Oriented Design and C++:


http://www.cs.rit.edu/%7Eafb/20012/cs4/s...





This post gives details and links for 2 Free C++ Books:


http://www.intelligentedu.com/blogs/post...





Here is a book titled "Common Sense C - Advice and Warnings for C and C++ Programmers":


http://script.bluebull.com/archive/c/adv...





I hope these help you.


Computer-teacher


No comments:

Post a Comment