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 reader 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

488 comments to 0.1 — Introduction to these tutorials

  • SilverAmd

    I just wanted to say I disabled adblock just for this site because it's so helpful

    • Thanks for inadvertently reminding me about mine. I normally disable mine for useful ad-supported sites, but although I recall disabling it on my laptop for the site (and telling Alex via comments section about an intrusive ad which may or may not have caused me to reenable it and forget about it; I can't recall for sure), it seems I've not done so on my desktop. Easy problem, easy solution!

  • Chris

    How does one get a login set up with this? Thanks!

    • Hi Chris!

      Registration is closed, the only two accounts are Alex' (Author of learncpp) and Devashish's (Who partially translated learncpp to hindi).
      You can however create an account at with the same email as you're using on learncpp to get an avatar.

  • nice information and it is useful for new programmers

  • ayush dixit

    Hey Alex, great article I am following this site for a month to learn c++ and other informative keep the information coming. thank you.

  • Aaron

    Hey there  Alex!
    Can I use your tutorials,edit them around a little bit,and make it into a class?

  • Chris

    How long does it take on avergage to complete the entire course or at least up to (including) Object Oriented Programming?

    • Hi Chris!

      It totally depends on how much time you spent here.
      Start to end times range from 3 to 12 months.
      The only time I found for OOP is 2 months, although, if you have experience in another language you could probably do it in a week or two (if you have holidays and no other plans, that is).

  • J.

    Hey, I have just begun my C++ journey! I am 14 years old and am lucky enough to have wealth and the time to learn this. I am extremely excited but I just wanted to know if there's any way I can support you guys? I know it's not easy to take time out of your day to write something to help others so I want to ensure that, while you make sure we are happy, you are happy too. Much support, J.

  • anubhav

    hey, Alex, could you suggest any of your page or some other page for learning java, please!!!!!

    • Christine Willis

      Hi Alex, thanks for the c++ tutorial. I am in my 60's and I want to learn this. I have come to your site via Ivan on tech. Cryptocurrency was my initial interest, now I've evolved into learning what is under the hood. I envisage a long interesting journey and thank you for making this possible.

  • Pravin

      Does this tutorial cover all the aspects of c++ or just the basics?

    • nascardriver

      Hi Pravin!

      It covers the core C++ language and some standard library functionality. No OS-specific/graphics-related/GUI features.

  • Mark

    I was wondering if these chapters will cover up the topics in computer engineering? Also, is there other websites (just like this website) for low lvl languages? And last question is which C++ textbook would you suggest for practice(a lot of practice)?

    • nascardriver

      Hi Mark!

      > I was wondering if these chapters will cover up the topics in computer engineering?
      They don't. learncpp teaches you the basics of C++, and very few about computers.

      > Also, is there other websites (just like this website) for low lvl languages?
      Pick a language and search for it. Most tutorials I've seen for other languages weren't written as well as learncpp.

      > which C++ textbook would you suggest for practice(a lot of practice)?
      I can't help you here. I don't like books about programming, because languages evolve and get updated, books don't.

    • Hi Mark,

      A book that Microsoft recommends on their tutorial vids is "C++ Primer 5th edition, by Stanley B. Lippman, Josée Lajoie and Barbara E. Moo"

  • ss

    Hi Alex,

    The C++ content you provide on your site is very good.

    Just a suggestion. If you could add some good diagrams to convey some of the concepts, that would be very helpful to grasping the concepts more easily and thoroughy.


    • Alex

      If in reading through the content, you run across anything you think would benefit from a good diagram, please comment on that specific article.

  • C++, I actually can't wait to dig in. I heard that they use it a lot in Games and that's my goal!
    I don't why but this site makes me feel pretty smart for a 17 year old, haha!

  • Ben Bistline

    Raspberry Pi, newer models, such as the 3, model B, still works with C++, even though I believe it is not pre-downloaded on Noobs?

  • Timoy

    Hi sir!
    Can I use a raspberry pi to  program c++ with your tutorial instead of a normal computer like laptop or pc? I don't have a pc or laptop to do programming.

    • nascardriver

      Hi Timoy!

      You can! Code::Blocks doesn't seem to offer an ARM version so you'll have to find an IDE that runs on your pi (or use a text editor + compiler).

  • Michael Roundtree

    Hi, I am going to hang out with you guys a little here at this site. I have a computer science degree; I have an undergraduate degree in math; I have a masters degree in math. I don't know a damm thing. I have been teaching math for the last 23.5 years and am about to retire in 4.5 years and am preparing for a second career as a junior programmer. If I could do it for 5-10 years I would be happy. I am using xCode on four Macs that I have at home.

  • john callander

    hi i am 42 years old and no longer work due to a variety of health issues i use a mac and have experience using windows and linux i know about components of a computer vpns torrents virtual machines etc but i have never learned programming what would you recommend? keeping in mind i need to go at own pace as i can't always rely on hands for typing. i mainly want to learn just for myself. many thanks for any suggestions and i wish a good day to all.

    • nascardriver

      Hi John!

      > am 42 years old
      Not too old to learn programming

      > what would you recommend?
      I'm not really sure what the question is here.
      Use whatever OS you like best.
      C++ is a complex language but the lessons here were written to be comprehensive to beginners.

      > i can't always rely on hands for typing
      No worries, this gives you more time to think about your code and reading lessons.

      Feel free to ask any questions that may come up and submitting your solutions to quizzes (There are quizzes/tasks every couple of chapters).

      • john callander

        Thanks so much for the reply. I’m very much looking forward to learning a new skill and appreciate that I can ask further questions if needed

  • Henry

    Hi Nascardriver and Alex,
    I am a computer science graduate currently an IT engineer at an engineering firm but I want to pursue a career in cyber-security and Artificial intelligence is C++ a good fit for me?

    • nascardriver

      Hi Henry!

      It is. AI needs high-performance to not waste time training, C++ does just that.
      Cyber-security is going to require a bit of everything, including C++.

  • 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.

      • Razamanaz

        C++ was originally written in C, which means that C can do whatever C++ can (in technical terms C is Turing-complete). C++ has a more convenient syntax for higher levels of abstraction and claims to free the programmer from the strong discipline required by C to avoid bugs and errors.

        The C standard is updated every 10 years or so. The latest revision is C11, published in 2011. Notwithstanding, independent implementations keep adding new features.

        C++ has been updated more rapidly recently to catch up with other players in the OOP arena: namely Java and C# (both inspired by C and C++).

        C and C++ are languages of the 21st century and should be taken into consideration by any serious programmer.

    • 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]