0.1 — Introduction to these tutorials


    Welcome to the Learn C++ tutorials! Above all else, these tutorials aim to make learning C++ easy.

    Unlike many other sites and books, these tutorials don’t assume you have any prior programming experience. We’ll teach you everything you need to know as you progress, with lots 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 are aimed at giving you some 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 will explore different parts of the C++ language. In the first chapter (chapter 1), you’ll get a broad but shallow overview of many fundamental C++ concepts, so we can start writing some simple programs. Further chapters will explore those concepts in depth, or introduce new concepts.

    Each chapter has a theme, with all of the sections underneath it being generally related to that theme. There is no suggested amount of time that you should spend with each lesson or chapter; progress through the material at a pace that is comfortable for you.


    Before we get started, lets hit on a couple of important goals of these tutorials:

    • Cover programming topics as well as C++. Traditional textbooks do a pretty good job of teaching the basics of a given programming language, but they often do not cover relevant programming topics that are incidental to the language. For example, books will omit sections on programming style, common pitfalls, debugging, good/bad programming practices, and testing. Consequently, by the time you finish the book, you may understand how to program in a language, but you might also have picked up bad habits that will come back to bite you later! One of the goals of these tutorials is to make sure that all of these incidental topics are covered along the way, in the sections where it naturally makes sense to discuss them. When you finish, you will not only know how to program in C++, you will know how NOT to program in C++, which is arguably as important.
    • Provide a lot of examples. Most people learn as much or more from following the examples as they do from reading the text. These tutorials will endeavor to provide plenty of clear, concise examples to show how to apply the concepts you are learning. We will also avoid (as much as possible) the twin evils: the magic hand wave (also known as ), where in the interest of space part of an example is omitted, and the unexplained new concept, where a new concept that is integral to the example is introduced without any mention of what it is or how it works. Both of these tend to lead to getting stuck.
    • Provide practice programs. The end of many lessons and sections will contain some exercises that you can attempt to answer on your own, along with solutions. You can compare your solution against ours to see what we did differently, or, if you get stuck, how we solved the problem. Then you can go back and refocus on the areas you need more work on.
    • Most importantly: have fun. Programming can be a lot of fun, and if you’re not generally having fun, you’re not in the right mindset to be programming. Tired or unhappy programmers make mistakes, and debugging code tends to take much longer than writing it correctly in the first place! Often you can save yourself some 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 a number of practices to maximize your learning experience:

    • Type in the examples by hand and compile them yourself. Do not copy and paste them! This will help you learn where you commonly make errors, as well as becoming familiar with compiler warnings and errors. Don’t just transcribe the programs mindlessly -- think about what each of the lines you are typing in does, and how it contributes to the way the program functions. If you encounter anything that doesn’t make sense, or that you don’t understand, that’s something to investigate further.
    • As you make mistakes or find bugs in your programs, fix them. Try to solve your own problems before asking others for help. Learning how to find and fix errors is a key skill to successful programming. Don’t neglect learning how to use a debugger (we’ll explain how in a future lesson) -- it’s a key tool in figuring out where your programs are going wrong.
    • Experiment with the examples. Change numbers and text to see what happens. Modify the programs to do additional things (e.g. if a program adds two numbers, make it add three numbers). Try to find different ways to break the programs (if a program asks for user input, try a variety of different inputs). You’ll learn more by modifying the examples than by simply following them.
    • Plan to spend some time with the quizzes. If you’re new to programming, you may find these challenging (and 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. You may need to try several different approaches before you find a path to success. It’s okay to look at the answer if you’re really stuck. Just make sure you understand how the provided answer works before proceeding.

    • Write your own short programs using the concepts you have learned. Nothing is better than practice.

    Common site-related questions

    Q: How do I sign up for the site? How do I get a login?

    All parts of this site are accessible anonymously -- therefore, no user account or signup is needed!

    Q: These tutorials were originally written in 2007. Are they still relevant?

    Yes, absolutely.

    C++ doesn’t change very often, and when it does, the new content is largely additive. The tutorials have also been updated periodically based on language changes and readers’ feedback.

    Q: Is there a PDF version of this site available for offline viewing?

    Unfortunately, there is not. The site is able to stay free for everyone because we’re ad-sponsored -- that model simply doesn’t work in PDF format. You are welcome to convert pages from this website into PDF (or any other) format for your own private use, so long as you do not distribute them.

    Q: What should I do if I get stuck on a concept?

    If you don’t understand something:

    • Read through the comments. Other readers may have encountered similar challenges.
    • Scan through the next lesson in the series -- your question may be answered there.
    • Use a search engine to see if your question (or error message) has been addressed elsewhere.
    • Ask your question on a site that is designed for programming Q&A, 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 that was hard to understand is easier with the additional knowledge and context provided by other articles.

    Q: What do I do if I forget what something means?

    Use the Site index. Look up any topics you want to know more about there, and you’ll find links to the lessons where that topic is discussed.

    Q: How do I get an avatar for the comment section?

    The comment section uses gravatars. You can create one on Click the “Create your own gravatar” button and sign up. Your gravatar will be connected to your (optionally provided) email address.

    Q: Can you do a dark mode for this site?

    Not easily, but you can! See

    Finally, one small nag: This site is free because it is ad-supported. If you find yourself enjoying the lessons, please consider disabling your ad blocker.

    Alright, let’s get on with it!

    0.2 -- Introduction to programming languages
    No previous lesson

503 comments to 0.1 — Introduction to these tutorials

  • Eric Paul

    This is one of the best site out there and I am happy for a great makeup on this site.

  • C. Flamingo

    Hi, I just wanted you to know that this is one of the best introductory tutorials on coding I have ever read, and I really appreciate how all of this is donation-based.

    When I was a student, I tried learning to code during Winter break in 2019. Once school resumed, I didn't have the energy nor time to commit myself to keep learning, but after trying to enroll in weekly courses to make websites and easy JavaScript projects, coding still felt very foreign to me. I continued because I really like the focus I have when I'm learning to code, something that I rarely feel with any other discipline in my life. That's why, I'm trying to seriously learn how to code now.

    I tried many different programs (Udacity, Coursera, other free websites) to gain an intro to coding, but none of them did as succinct a job as this website. All too often, those programs brush past basic history and explanations out of fear of overwhelming the learner, but by doing so, I was always stuck with questions and wanted more concrete definitions–nothing too lengthy but at least three sentences long.

    This website gave me the depth and explanations I wanted to better understand how coding came to be, and I truly appreciate how everything is so concisely written without totally washing out the quality of the content. I'm so glad I found this website again.

    Thank you to the website maintenance team and donors who ensure this website keeps going. It's truly amazing.

  • Hey thank you for the website. Due to the lockdown, I was thinking of reworking my C++ skills. I did not have knowledge to compile complex programs. My only bet was to trust the makefiles of wonderful open source developers and execute the makefiles. My short term goal is to learn to build projects with increasing complexity.

  • ThachHoang

    Just want to leave a comment here to say at least I've tried the comment section :-)
    Will come back later and reply my own comments to see if I can learn.
    Thank you for all the advice. It's a very helpful mindset for a beginner like me.

  • Ritu

    Thanks for putting up this great website

  • HolzstockG

    Look at the end of sentence.

    C"++ doesn’t change very often, and when it does, the new content is largely additive. The tutorials have also been updated periodically based on language changes and reader feedback."

    Shouldn't it be
    "C++ doesn’t change very often, and when it does, the new content is largely additive. The tutorials have also been updated periodically based on language changes and readers' feedback."

  • Shakib Saydur

    Hello, is the comment function alright?

  • ali imanzadeh

    hi.i start a "winwows desktop wizard" project in visual studio that itself has afew code . this project has wWinmain instead main method . wwinmain is not part of cpp syntax . how is it posible? . do you teach this topic? . please explain in detail

    • nascardriver

      Windows desktop applications have a different entry point. This is done through a language extension a macro, or code that you can't see. Unless you have a reason to create a windows desktop project, use the type that's suggested in the tutorial.

  • Gabriel s

    Still dont know how to add an avatar. Feel like doing great at the introduction

  • longfish

    Just sign up an account, wanna try the comment function.

  • Omar M

  • lieriw

    thank you! I 'm a beginner program who come from china.

  • Just to test my automatic comments access script.

  • EJW

    I use CleanBrowsing DSN filter service and it's blocking out your site's ads. I've tried adding your site to the filter whitelist but that appears to be ineffective. Do you have any suggestions as to how I can permit ads on your site only?

  • Lucky

    Lol Programming Lesson 1: Everyone uses dark themes ;P Very excited to learn C++, thank you for the free resource! Ad Blocker Off (Which is rare lol)

  • Vitaliy Sh.

    but you might might also have picked up

    U+1F437 Typo: double might.
    ️I'm lumberjack, and i'm okay... la-la-la-la all off the day...

    PS: Are "Emoji" get stripped out there?

  • Vitaliy Sh.

    Please change to "https", as it redirects there anyway.

  • Vitaliy Sh.

    ... Q: How do I sign up for the site? How do I get a login? How do I get an avatar for the comment section? ...

    "How do I get an avatar for the comment section?" was split to "Q: How do I get an avatar for the comment section?" below.

  • Vitaliy Sh.

    ... Don't be discouraged if you don't get the right answer the first time. ...

    "get the right answer outright"?

    Because "outright" fits better:

    • nascardriver

      "outright" doesn't fit. "right" is used as a synonym to "correct".

      • Vitaliy Sh.

        Link above:
            1     Wholly and completely.
            1.1  Directly or openly.
            2     Immediately or instantly.
            2.1  Not by degrees or instalments.
            1      Open and direct.
            1.1   Total.
            1.2   Clear and undisputed."

        Are you sure, sir?

  • Vitaliy Sh.

    <li>...Traditional textbooks ... a given programming language,  ... you understand how to program in a language, ...</li>

    I'm sorry: "program in the language" ("language" already mentioned in the paragraph)? Can't get it myself (a vs the).

    PS: ... but you have a ton of bad habits ...
    Is "you" needed there? I searched for "but have", and found that pronouns may be omitted with "but".

    PS2: ... or find bugs in your program, ...

    • Vitaliy Sh.

      You may:
      leave a comment about typos you've found there;
      ask a question about topics covered in here (not from another sections; each section have it's own "comments part");
      say "thank you" or "else";
      answer to an person comment/question;
      do something similar;

      That is (probably) not a forum, sir.

  • Yunliang

    It's great! Thanks.

  • Vitaliy Sh.

    ... This tutorial will endeavor to ...

    "these tutorials" ?

  • Vitaliy Sh.

    ... <As you type in the examples,> (Do?) think about why each of the things you are typing in make sense. ...

    Can you, please, delete a part between the "<>"? Context in that bullet point is looks sufficient.

Leave a Comment

Put all code inside code tags: [code]your code here[/code]