Introduction to C++
Welcome to the C++ tutorials — what these lessons cover and how to get the most out of them.
Chapter 1 of 1 — Introduction to C++
Welcome to the C++ tutorials! Above all else, these tutorials aim to make learning C++ easy.
Unlike many other resources, these tutorials don’t assume you have any prior programming experience. Everything you need to know will be taught as you progress, with plenty of examples along the way.
Whether you’re interested in learning C++ as a hobby or for professional development, you’re in the right place.
Lesson Structure
The lessons in this introductory chapter give you context around what C++ is, how it came about, how programs work, and what software you need to install to create your own programs. You’ll even write your own first program.
Further chapters explore different parts of the C++ language. In the first chapter, you’ll get a broad but shallow overview of many fundamental C++ concepts so you can start writing simple programs. Later chapters go deeper into those concepts or introduce new ones.
Each chapter has a theme, with most lessons underneath it being generally related to that theme. There is no suggested amount of time to spend with each lesson or chapter — progress at a pace that is comfortable for you.
Goals
Before we get started, here are a few important goals for these tutorials:
-
Cover general programming topics as well as C++. Traditional textbooks teach the basics of a language but often skip programming style, common pitfalls, debugging, good and bad practices, and testing. By the time you finish, you’ll know not only how to program in C++, but also how not to program in C++ — which is arguably just as important.
-
Provide lots of examples. Most people learn as much from following examples as they do from reading text. These tutorials provide plenty of clear, concise examples to show the application of concepts you are learning. The twin evils — the ellipsis (where a necessary part is omitted) and the unexplained new concept (where a new idea is introduced without explanation) — are avoided as much as possible.
-
Provide practice programs. The end of many lessons contain exercises you can attempt on your own, along with solutions. Compare your solution against ours, see what we did differently, and refocus on the areas you need more work on.
-
Have fun. Programming can be a lot of fun, and if you’re not generally having fun, you’re not in the right mindset. Tired or unhappy programmers make mistakes, and debugging code takes much longer than writing it correctly in the first place. Often you can save time by going to bed, getting a good night’s sleep, and coming back to a problem in the morning.
Getting the Most Out of These Tutorials
As you go through these tutorials, we recommend these practices to maximize your learning:
-
Type in the examples by hand. This helps you learn where you commonly make errors and become familiar with diagnostic messages from typos. As you enter each line, think about what it does and how it contributes to the overall program.
-
Fix your own mistakes. Try to solve problems before asking others for help. Learning how to find and fix errors is a critical skill. Don’t neglect learning to use a debugger — it’s a key tool in figuring out where your programs go wrong.
-
Experiment with the examples. Change numbers and text to see what happens. Modify programs to do additional things. Try to find different ways to break them. You’ll learn more by modifying examples than by simply following them.
-
Spend time with the quizzes. If you’re new to programming, they may be challenging — that’s normal as your brain acclimates to the programming mindset. Don’t be discouraged if you don’t get the right answer the first time.
-
Write your own short programs. This reinforces your learning and improves retention.
What If I Get Stuck?
If you don’t understand something or feel stuck:
- Read through the comments — other readers may have encountered similar challenges.
- Scan through the next lesson or two — your question may be answered there.
- Use a search engine to see if your question or error message has been addressed elsewhere.
- Ask an AI to explain something to you (keep in mind the information may be partially incorrect).
- Ask your question on a Q&A site like Stack Overflow.
If all else fails, skip the material you don’t understand and come back to it later. You may find that something hard to understand becomes easier with additional knowledge and context from other articles.