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!

Tutorial structure

The tutorials 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 general theme, with all of the sections underneath it being 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 understand how to program in a language, but you have a ton of 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. This tutorial 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. As you type in the examples, think about why each of the things you are typing in make sense.
  • As you make mistakes or find bugs in your program, fix them. Try to solve your own problems before asking others for help.
  • 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 as much from modifying the examples as you will by following them.
  • Write your own short programs using the concepts you have learned. Nothing is better than practice.
  • Learn to debug your programs when they don’t work. This is critical to solving your own problems, and is a skill that many new programmers skip to their detriment. We’ll have more information on how to do this in a future lesson.

Note: The majority of the examples in the tutorials are full programs that you can compile and run yourself. However, occasionally the examples will be “snippets” of code that are designed to quickly illustrate a concept. Because these aren’t full programs, they won’t compile without some additional work. You can turn these into full programs yourself, if you desire.

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.

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

Yes, absolutely. C++ doesn’t change very often, and these tutorials have been largely kept up to date.

What should I do if I get stuck?

If you don’t understand something, read through the comments. Other readers may have encountered similar challenges. Second, try scanning through the next lesson in the series -- your question may be answered there. Third, use a search engine (we recommend Google) to see if your question (or error message) has been addressed elsewhere. Fourth, 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 when needed. You may find that something that was hard to understand is easier with the additional knowledge and context provided by other articles.

Alright, let’s get on with it!

0.2 -- Introduction to programming languages
No Previous Lesson

355 comments to 0.1 — Introduction to these tutorials

  • Ryan

    Hello Alex & nascardriver!

    I'm currently 18 this year, and I'm very interested in these sort of languages,
    e.g. Python, Java, Java Script, C++ etc...

    So, which one do you guys would recommend me first? I'm a TOTAL Beginner tho...
    But I have tried coding HTML, that's it, Only HTML coding, no other stuff...

    Is it too late for me to start programming?
    and also,
    which language is the Best to be learned for ppl like me who loves:
    <li>Hacking into Games and Applications</li>
    <li>Program and Software and Apps Developer</li>
    <li>Cyber Security and Network kind of stuff</li>
    <li>Rear-based Website Script Programming</li>
    <li>System and Database Analysis stuff</li>

    Thanks bunch!

    • nascardriver

      > HTML
      HTML is not a programming language and is nothing like the other languages mentioned.

      > Is it too late for me to start programming?

      > which one do you guys would recommend me first?
      Depends on what you want to do. If you learn C++ first you'll be able to learn the others in no-time.

      Ordered by difficulty

      > Hacking into Games and Applications

      > Program and Software and Apps Developer
      Java (Unless you need high performance for desktop applications, then it's C++)

      > Cyber Security and Network kind of stuff

      > Rear-based Website Script Programming

      > System and Database Analysis stuff
      Any scripting/math language and all database languages

      • Ryan

        Wow! Thanks a lot nascardriver!

        One more if I may, some U / college offers me (in Asean countries) Computer Science in Technology OR Computer Science in Media...

        It's like the IT includes In-depth Programming and Cyber Security courses,
        while the C.Sc in Media exchange those Cyber Security into Basic Designs and Animation...

        Which course will be a better option for the current market industry nowadays, Games & Apps Development? Or Cyber Security & Networks?

        Thanks again,,

  • Bughda

    Hi Alex!  Can I use these tutorials for learning C?  I find the structure of your tutorials very nice and I couldn't find a similar one for learning C.  Thanks.

    • nascardriver

      Hi Bughda!

      C++ does everything C does, you can compile C code with a C++ compiler.
      If you know C++ you know C. The tutorials here will teach you a lot of C++ exclusive features that you won't be able to use in C, so if you use learncpp to learn C you'll spend some time learning things that won't be of any use to you. If you think wasting a bit of time is better than learning C somewhere else, sure, learn C++ instead.

      Everything from chapter 8 onward appears to be mostly C++ exclusive, you can skip those.
      Everything with std:: in the title is C++ exclusive, you can skip those, however future lessons might built upon those features so you'll have to find a C equivalent to those lessons.

    • Alex

      My 2c is:
      * If you just want to learn C, you're better off finding a C tutorial than trying to extract the C bits from this one.
      * If you learn C++, learning C (and many other languages) will be a lot easier.

      So it really depends on what your end goal is, and how quickly you want to get there.

  • Ray

    Hi, so i am quite young and was looking in to under standing C++ coding a little more than copy and pasting junk code into a SLN for video game cheats (I get paid for it :P). But i was wondering if this could help me code or atleast help me understand some game cheats and games in general?

    -Thanks have a great day

    • nascardriver

      Hi Ray!

      This will definitely help you.
      After you've finished the tutorials here all that's left to get into gamehacking are OS specific API calls (CreateRemoteThread, LoadLibrary, mmap, you name it) which you'll have to learn on your own. Once you've gained access to the game everything on learncpp will come in handy. Additionally I suggest you to learn assembly to get into reverse engineering. Don't expect to be able to write a decent cheat within a year. If you're selling Ayyware you should at least understand what's going on in the source.

  • Do you have to know this if you want to be a computer programmer

    • nascardriver

      Hi ZAID!

      This depends on how you define "computer programmer". It's like asking "do I need to know polish if I want to become a translator?".
      Are you planning on writing high performance low-level programs? You'll probably need C++.
      Are you planning on writing website? You won't ever need C++ but knowing C++ will make learning other languages easier.

  • roy

    hi alex,c is used for automobile,airplane.
    java for app.  c++ is mainly for games?
    i think c++ waste a lot time on itself, make design difficult and unsafe.
    what you think? any big change will in c++ in future?

    • nascardriver

      Hi roy!

      C++ is used for almost anything that runs on your computer.
      If you need speed, use C++.
      If you need an embedded application (cars, machines, etc.), use C (There are chips for everything nowadays, you could even use python).
      If you need portability across multiple operating systems and you don't need speed but have RAM and don't care if your user needs to install Java, use Java.

      "i think c++ waste a lot time on itself, make design difficult and unsafe."
      Once you've learned C++ it's way more efficient than C and not less safe than C.

      "any big change will in c++ in future?"
      C++ is being maintained and updated every ~3 years, C doesn't get any updates.

    • Alex

      C++ is often used for games, simulations, web browsers, databases, operating systems, and other applications where high performance and discrete resource management are important.

      C++ does have some legacy cruft that can be dangerous. However, with proper best practices, much of this can be mitigated. I don't think this will change in the future, otherwise backwards compatibility could be impacted.

  • JohnB

    Hoping you can give me some direction. I did my first programming on a TRS-80 Model 1 that saved on a cassette tape. Sometimes. I went on to learn BASIC on the Model 3 with a disc drive as large as a vinyl record. I wrote some games in BASIC on an Atari-400 then learned FORTRAN in college which I used for a lot of physics and engineering classes, becoming a very good algorithm programmer. Went from there to Matlab that I used through graduate school and have used since 1988. I'm a very good scientific programmer and have used Macs, PCs and am currently on a Linux box. Like a lot of veteran aerospace engineers I can program FORTRAN in any language: Ada, Python, C, C++, etc. If I have something to start with I can figure out the syntax with help from StackExchange and others. But I don't really know the languages and I've never really had any training in C or C++.

    I now have a job opportunity but I need some formal training in C++. I've checked out a lot of sites but they start way to basic for me. I don't mind slogging through some background material, like "what is a variable" though I understand most of it already. However, I don't have a ton of time here. I kind of need to get reasonably proficient in a few months. As I already think like a programmer I'm pretty sure that's doable but I'm spending too much time figuring out what is relevant and what is background. I have always wanted to learn C++ but haven't really had the motivation. Now I do. Specifically on the gcc compiler, so if you know of a decent gcc IDE???

    Can you tell me how I might use this site to gain a working knowledge of C++, or can you recommend a website of book that might accomplish this task more efficiently than the Russian guy on Udemy? I like your website as much as any that I have found and it seems like the order of the sections could be tailored to a guy like me.

    • nascardriver

      Hi John!

      "a few months"
      You'll be able to learn most of C++ in a few months, but C++ is huge, you won't learn everything.

      "decent gcc IDE"
      CodeBlocks, Eclipse CDT and CLion are the major Linux IDE's I'd say.

      CodeBlocks: I think it's easy to use and it's used in the tutorials here.
      Eclipse: Do you like customization? You'll like Eclipse. It'll take some time to figure out certain things but once you've got the hang if it it's great (There are minor bugs).
      CLion: I don't like the JetBrains IDEs and it's not free for non-students.

      You can also use a text editor (eg. Visual Studio Code) and make. You'll have to learn how to write makefiles but that's quickly done.

      "Can you tell me how I might use this site to gain a working knowledge of C++"
      Since you already know several other languages you'll probably be able to skip the first few lessons of each chapter. If you find yourself having problems with lessons you can jump back to previous lessons still.

      • JohnB

        Thanks! I started reading through these tutorials and was glad I went ahead with the simple stuff. Always helps to make sure you have a solid platform. But, I'm going to have to figure out the IDE and building part. I have a Linux box at work that I have no admin control over. At home I use a Mac. I'll see if my sysadmin will put Code::Blocks on my machine. Otherwise I'll have to figure out QT Creator. My early assessement is that it wants me to create projects and it doesn't seem to use <iostream> so there'll be some reconciliation that I'll need to do.

        • nascardriver

          "I’ll have to figure out QT Creator"
          QT Creator is meant to be used to design forms (windows). I've never heard of anyone using it as an IDE, it should be possible though. QT Creator uses gcc to compile so you'll always have the option of compiling without an IDE.

          "it doesn’t seem to use <iostream>"
          iostream is used to output text to a console. This is only used to make it easier for learnes to understand what's happening in the tutorials. All tutorials can (but shouldn't) be completed without iostream and are not intended to teach you the use of iostream features (apart from some lessons).

  • A new c++ pleb :D

    I just came here recently to learn c++ and I am mostly amazed on the fact that you're still keeping it up to date! Keep up the good work mate!

    Wish you all the blessings and goodies for you!

  • Victoria

    Hi Alex,

    I was told that if I wanted a foundation to learn HTML and JavaScript, C++ would be a great place to start.

    Would that be true?

    I don't know anything about coding, but I do know that in the future, I'd like to create some sort of immersive machine that allows people walk into it and have an emotional experience. I know that sounds vague, but that's the general idea. People have told me that maybe I'd like to look into VirtualReality, but I want to go more into the psychological well-being of a person versus gaming.

    Sorry, That was probably too much detail huh? Hahaha! My point is, is C++ a good place to start? Thanks in advance!

    • nascardriver

      Hi Victoria!
      C++ is probably one of the hardest languages to start with. The thing is, if you know C++ you can learn pretty much any other scripting/programming language in no time.
      If you need JavaScript now you might as well start with JavaScript, it's a heck of a lot easier than C++.
      HTML is a whole different story, it's not a programming or scripting language and it doesn't have any active functionality, you write it, it's there, that's it, all it is are a bunch of tags mixed together. Knowing JS/C++ won't help you with HTML, knowing HTML won't help you with JS/C++.

      TL;DR: C++ is a bad place to start, if you don't think you'll need it don't learn it.

    • Alex

      I think Nascardriver is right -- if you want to learn HTML and Javascript, then learn HTML and Javascript. Once you know Javascript, C++ will be a lot easier to learn if you want to do that later.

      Also, consider your longer term goal -- for your future vision, is that something you want to be an application or a web experience? If application, then C++ might be a good choice. If web experience, there are probably better choices for tech.

  • Michael

    Hi Alex,

    I am 51 years old, with only rudimentary (and outdated) knowledge of any computer language.  I tried to learn BASIC in the mid-70's but didn't get very far.  I used to think that I was too old to try to tackle something like this, but I'm going for it anyway.  I don't have a lot of time each day to devote to learning, but from what I've seen of this tutorial, if I end up slipping away from it for a couple of weeks or so, I'm not necessarily going to have to start all over again.  Thank you for developing this tutorial.

  • adli

    hey alex. Am I too late to learn this?im 18 yrs old

    • nascardriver

      Hi adli!
      You're not.
      Usually, the older you are the less time you have (work, family etc.) so it will take longer than for eg. a 13 year old. But it's never too late to learn something new. Especially when you're still 18, you're probably in school, university or vocational training so you should have plenty of time.

  • yogesh brar

    Hi Alex
    I want to ask if I need any book for the reference aside from these tutorials? If so which book?
    Since I want to go into game development world, is this a good start for me? Any guidance would be appreciated.

    • Alex

      You don't need any reference material while you're going through these tutorials.

      These tutorials are designed to teach you most of the C++ fundamentals. They should be an excellent starting point for getting into C++ game development.

  • Travis

    Hi, thanks for creating this amazing resource. Just wondering, are these tutorials up to date with C++17? If not, is C++17 too different from previous standards to be worth learning until proper compiler support? Thanks

    • Alex

      I haven't added lessons for C++17 yet -- but C++17 largely is additive to the existing language, so you won't be wasting your time at all. After you finish these tutorials, you can find a "What's new in C++17" elsewhere on the internet and learn about the newest additions.

Leave a Comment

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