Learn C++ Programming

Learning programming definitely isn't an overnight thing, and takes a large amount of hard work and dedication (especially with C++). This guide will help you through the process.

Steps

  1. Learn about C++'s history. The best way to start programming a language is to learn its roots. Even though you may not understand everything that you read, some of these pages will introduce you to important terms that will come up later (such as "Object-Oriented Programming").
  2. Install a C++ compiler (and possible IDE). A compiler is required for programming in C++, because the actual source code has to be compiled into a file that your computer can run. If you are using Windows a good option would be Visual C++ 2010 Express, or if your using Linux a good one is Geany. Both come with an IDE (independent development environment) built in, which can make the process of writing source code easier. (NOTE: Many people online will recommend that you use the Bloodshed Dev-C++ IDE and compiler. DON'T. It has not been updated in 5 years and has pages and pages of known bugs, listed here: http://sourceforge.net/p/dev-cpp/bugs/)
    • Learn how to use your IDE efficiently. Some IDEs that are out there have their own individual quirks that could get in the way down the road, so it would be beneficial to read through or keep a reference for the different options and settings of your IDE.
  3. Choose a tutorial or two to start learning C++. This step is, along with the compiler, one of the most important steps of all. There are a few things that you have to make sure of during this step. First of all, make sure the guide is written for complete newbies to programming, as those are the most thorough in their descriptions. Next, make sure that the code in the tutorial follows the C++03 standard or even the new C++11 (still not standardized, so beware of compiler issues), because modern compilers will have trouble compiling outdated code, or will just reject it altogether. A few good ones are c programming.com's C++ tutorial and the tutorial at www.cplusplus.com/doc/tutorial/.
  4. Try out each new concept. An important part of programming is not only reading about the different concepts, but using them in your own code. Copy-pasting the code into your IDE will only go so far. It is much more beneficial to type out each example and even try creating your own program ideas that use the concept being taught to maximize the amount of information retained.
  5. Learn from other developers. One of the best things about programming is that no matter what level of skill you have in programming, there will always be source code readily available that is at that same level or one step above you. A good way to learn from more complicated source code is to read through until you reach a point which you don't understand, then try to work it out in your head; if you don't know a certain part of the code, read about it in your tutorial or reference material until you do.
  6. Work through problems using the concepts you have learned. The absolute best way to retain what you learn isn't just writing out source code examples, but actually accomplishing a set task with them. Both c programming.com and Project Euler have good problems that you could try solving to apply concepts in real-life situations. If you absolutely can't create an algorithm for a problem, then as a last resort check online for one done by someone else and learn from it. What's the use of solving a problem if you don't learn from the result?
  7. Help others who need help. Now that you have learned about C++, you should start helping other newbies online with their problems and get them started on the same journey you had! Don't get frustrated if the person who asked you for help doesn't want to listen to your advice: someone else could learn from the answer you provide even if the original poster didn't.



Tips

  • Don't get frustrated! Programming can be confusing at some points, but that definitely doesn't mean you should just throw away all your progress and quit! If a certain guide does a bad job at explaining a topic, try reading another one on the subject; it may not be you that's the problem!
  • Always comment your source code! Even for simple, self-explanatory code, it can never hurt to write a short explanation of the program's function at the beginning. It is also a good habit to get into for when you are programming large, confusing software later on that you might understand, but anyone else reading would be confused about.
  • If you get errors while compiling, re-read the source code again and see if you can find errors. Although the errors themselves can seem cryptic, they are trying to tell you what is wrong, so see if you can learn anything about the error from them.
  • If you get errors during run-time, then the problem isn't a syntax issue, but instead is a problem with your algorithm. Try to write down the exact things your algorithm is supposed to do, then compare them with your source code. Worst case scenario, bring the code you have to an online community and see if they can find problems for you, but make sure to ask nicely! The people who are helping you are using their time they could be programming money-making software to answer your questions, so be grateful!
  • Go at your own pace.
  • You can learn C++ from Google Play store or the Appstore by searching "Learn C++."
  • You can also get a book about C++.

Warnings

  • C and C++ are very low-level programming languages, meaning you have the possibility of crashing your computer with faulty code or with purposefully malicious programs! Make sure NEVER to compile and run programs that have "#include <windows.h>" in them unless you're ABSOLUTELY CERTAIN you know what you are doing, and even if you do know what you are doing, try to avoid it at all costs.
  • Make sure your compiler and tutorial are up-to-date! Outdated compilers can lead to valid source code not compiling or weird errors at run-time. The same can be said about tutorials.
  • Lots of Antivirus will think whatever you make is a virus! Be sure to add your program to exclusions and possibly turn off your Antivirus so your program doesn't get deleted!

Related Articles