Search

0.1 — Introduction to these tutorials

Welcome!

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.

Goals

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
Index
No Previous Lesson

304 comments to 0.1 — Introduction to these tutorials

  • You should add that DuckDuckGo search engine is often better than Google for programming-related questions

  • nice. Learned a lot from this site. Really helpful.

  • Hello, can I make Polish translation of your tutorials?

  • nikos-13

    Hey Alex! I found this challenge in the internet : "Make a program that takes first name, last name, and birth year, month, date and stores it to a .txt file." I know some things from your tutorials, but what about the .txt file? Is is something that we will cover to these tutorials?

    • Alex

      I cover text files in chapter 18. However, just because it’s in chapter 18 doesn’t mean you need to read everything between here and there to use that functionality.

      • nikos-13

        So i can just ignore some chapters? Are there chapters that i must read in order to understand the others?

        • Alex

          Most chapters are mandatory reading (as later chapters tend to build on earlier chapters). The ones that are optional reading generally have a note in the first paragraph indicating they can be skipped.

  • amir

    Really nice place you created here! Thank you very much Alex. ๐Ÿ™‚

  • AMG

    Alex,
    You made a great job, and it’s truly amazing you keep answering to everybody. For your readers, I would highly recommend to read all comments and questions after each section, and try to answer them. Without any doubts, this site is one of the best source for self learners.

  • Keith

    I
    I don’t want to pay for Google services so I would like free no inserted into my account

    • Alex

      I’m not sure what you mean. Google search is free to everyone, and it’s a great resource to turn to when you’re stuck on a particular problem. In almost all cases, someone else has encountered the same problem that you’re having, and someone else has solved it. ๐Ÿ™‚

  • Hello

    Thank you Alex for free knowledge.
    I am so grateful for this

  • Nouman Ahmed

    i cannot find tutorial on this page?

    • Alex

      At the end of each lesson, there is a link to the next lesson in the series. You can also access them directly from the site’s main page.

  • I really want to learn C++ and can create my own programs. This tutorial will useful for me. Thanks for sharing!

  • Peter (something-something) :)

    Hi!

    I know that this website is ment for C++, but if you can, I would love if you could help me with C.
    I have a problem with a code, and have not been able to find any answers. If you could help, it would be awesome! ๐Ÿ˜€

  • Hi

    Thank you very much for CPP lessons,

    I have used your lessons to develop my arduino encoder reader progrem

    Thanks

  • My dear c++ Teacher,
    Please let me express my suspicion that Google read our messages here, so we have to do what should do, performing the law of silence.
    With regards and friendship.

  • Don jose

    Hi Alex,

    I am trying to find linked list chapter in your tutorials, can you please help me to find that chapter

    If not available in your tutorials, please suggest me some good links for understands the concept in depth

    Your tutorials are very simple, effective and easy to remember, that’s why I always try to find things here

    • Alex

      I don’t have a linked list tutorial yet. I’m hoping to get around to writing one in the next few months, after I finish up the chapter on move semantics. I’m not aware of a good tutorial elsewhere, mainly because I haven’t looked.

      • Don jose

        Thanks Alex for your quick replay, I keep eye here to see Linked list tutorials. In the mean time I try to understand the concept however I want to understand from your way of presentation

  • Matheus

    Thank you for this tutorial. Best C++ programming tutorial ever. =)

  • My dear c++ Teacher,
    Please let me say that in municipal Library of Mauriac (France) where I spent last 4 days ads where not visible and also when I did click on [Post Comment] for send you message, output was:
    "Forbidden
    You do not have permission to access this document.
    Web Server at learncpp.com"
    Here in municipal Library of Neuvic en Corrรจze (France) ads were visible and did click on them till disappeared. In some municipal Libraries I get same "Forbidden" message.
    With regards and friendship.

  • My dear c++ Teacher,
    Please let me say, in municipal Library (Bibliothรจque municipale) of Riom es Montagne (France), where I’m just now, I did some 10 clicks on adds of your site and then disappeared. I hope this message be sent at your address.
    With regards and friendship.

  • My dear c++ Teacher,
    Please let me say that in municipal Library of the town Saint Flour, France, where I spent last 3 days, I tried send you comment but after have clicked [Post Comment] I seen on screen "Forbidden access at cpp.com". I have met similar problem in other towns municipal Libraries. Now here in "Office de Tourisme" of the town Riom es Montagne, I hope this message be sent at your address.
    On the other "hand" at Saint Flour I did many clicks on adds of your site and never disappeared, but here after have clicked 3-4 adds, they disappeared as is the usual case.
    With regards and friendship.

  • Abheet

    Disabled add-block, just to support you!
    This website is an excellent beginner spot.

    Thanks a lot for constantly updating this website.
    Keep it up ๐Ÿ™‚

    • My dear c++ Teacher,
      Please let me say Mr. Abheet that disabled add-block does not support Teacher. Clicks on adds support, and it’s easy. Normally, after 10-15 clicks, they disappear. Indeed you should wait till ad’s URL be visible, that is done in 1-2 seconds. So you should only spent half minute for support Teacher.
      With regards and friendship.

  • My dear c++ Teacher,
    Please let me say that I have seen that my message few minutes ago is accepted by your server, so I send present message on that you say: "The best and fastest place to get answers to your questions is on a site designed for programming questions and answers, like Stack Overflow.".
    I sent them question about Mr Bjarne Stroustrup book "The C++ Programming Language" where he defines function sqrt() although it is standard. See at
    http://stackoverflow.com/questions/42021508/why-does-stroustrup-in-the-c-programming-language-3rd-edition-online-defin
    Administrators put it on hold and eventually closed it, claiming it is "primarily opinion-based". But every answer is primarily opinion-based.
    Indeed two Gentlemen answered and two others commented it.
    Then, do you suggest me continue ask them questions?
    With regards and friendship.

  • I think it is right place to start learning c++ again after many years. Thanks

  • Stephane

    I am a programmer because I saw this website.

  • Lalit

    Beautifully explained and written.  The best approach to learn c++ i have seen so far, simple and powerful. I was trying to explain some concepts to a learner of c++ and landed here. I appreciated the style of explaining and i myself got hooked. Awesome.

  • vimanyu

    Excellent site thank you so much for this… Going to start today ๐Ÿ™‚
    BTW I don’t see any ads on this website buy it says that its ad sponsered??

  • Alex

    Keep reading. Free C++ programs are covered later in this chapter.

  • I love it so much that I have to buy it

  • mrcdog

    A+ job Alex. Brand new to C++. When I learned Python, I strictly used IDLE for my GUI. What do you recommend for C++?

  • keerthanan

    i’ll give my best

Leave a Comment

Put C++ code inside [code][/code] tags to use the syntax highlighter