The course is part of this learning path

Start course
2h 17m

This course provides you with a solid understanding of the fundamentals of C++. We will take a look at the components of the programming language and then put these into practice through a couple of projects that we will run through at the end of the course.

Learning Objectives

  • Learn how to store different types of data in main memory
  • Understand how to manipulate and perform operations on that data, including performing arithmetic on numbers
  • Understand how programs make decisions
  • Learn how you can write your programs to communicate with users

Intended Audience

  • Beginner coders, new to C++
  • Developers looking to upskill by adding C++ to their CV
  • Experienced C++ programmers who want to stay sharp!
  • College students and anyone studying C++


This is a beginner-level course and so no prior knowledge of C++ is necessary.



Previously we looked a lot at how data is held in memory in the form of variables and that these variables and the values they hold have a type, that is, a data type. Now we're going to focus on becoming good software engineers with a simple form of documentation in the form of comments which use special syntax to tell the compiler to ignore what we're writing in them. The usefulness of comments is that we can leave notes and descriptions of our code and even reminders without the compiler trying to compile things that aren't C++. Let's take a look at both single and multiline comments. In Visual Studio, I'm going to create a new project, make sure that it's C++ and that it is an empty project and hit 'Next'. For this project, I'm going to call it commentFun and then I'm going to hit 'Create'. So, inside of here in the source files, I'm going to right click, go to add new item as we always have and create main.cpp. Inside of this source code file, I'm going to include iostream using namespace standard, int main(). So, the first thing we're going to do is practice with multiline comments. Multiline comments sometimes also called C-style comments, after the programming language C, the predecessor of C++, is actually the older form of comments. With this style we make use of opening and closing comment delimiters that define where the multiline comment begins and where it ends. So, let's write a multiline comment with information about me and about the course at the top of the program. So, we can even put it before the include iostream if we would like. You'll notice there is a forward slash star and a star forward slash to indicate where the comment begins and where it ends. Inside here I will put the complete C++ Developer Course and then Instructor: Dr. John P. Baugh. Awesome. So, you notice that I can still compile and run this application. It's not really doing anything but I can still run it and this did not interfere with the compilation. It didn't look at it and say, "Oh, that's not C++, I can't compile that." When obviously this is written in natural language, this is not C++ syntax in here, just these are C++ syntax indicating the comments beginning and the end. So, the other style of comments is called single line comments. As the name suggests, you can only write a single line of comments. You indicate where the comments starts but it automatically ends at the end of the line on which it is written. So, there's no closing delimiter. Let's declare an int variable named age and put the value of 30 in it, inside of main. And we're going to put a single line comment next to it that says, this is my current age. These comments are also very useful for documenting our code. If you only have a little bit of information or documentation to provide or very short comment, then single line comments are ideal. So, you notice I can still run this program and there's no problem. It's not doing anything really that we can see because I'm not printing anything out, but you notice that the comments are not interfering with the compilation process. If I removed the comment and then tried to run this, it would give me a problem. It would say there were build errors, would you like to continue and run the last successful build? I can say no and I can look at the errors down here and it says there's quite a few of them because it's like I don't know what this is, I expect a semicolon at the end, this is an undeclared identifier, there's a syntax error here. It's all over the place because that is not valid C++. If I put the comment in front of this, tthe two forward slashes, then I know that it's a comment and the program knows this and it will ignore them. Excellent. Now, as a challenge, I want you to do two things for me. First, I want you to edit the multiline comment at the top of the source code file and indicate the lecture title which is comments above where the instructor name is. Second, I want you to create a double variable and give it the value 0.06 and put a comment next to it indicating that it's the sales text for Michigan which is in fact currently 6%. So, try this challenge out. Pause the video now and come back when you're done or if you're having trouble and we'll work on it together. Okay, did you conquer this challenge? I hope you did. But even if you didn't, that's okay, we'll do it together here. So, the first thing I asked was that we want to edit the multiline comment. So, we're going to do this before the instructor name and after the course title, I'm going to put lecture title and I'll put comments. Now if you just wrote Comments, that's fine too. The point is that you know how to edit a multiline comment. I'm also going to create a double and we're going to call this salesTax = 0.06; and then I will say, This is the Michigan State sales tax. Excellent. So, that's pretty awesome. We've accomplished a lot in this lecture. Bit by bit, you are increasing your C++ programming knowledge and you learned the crucial and fundamental topic of comments in this lecture. They may not seem like much but they really, really help us remember what we were doing in code and also other developers with which we might work. In the next lecture, we'll start looking at different operations you can perform on data including both variables and literal values. So, I'll see you there.


About the Author
Learning Paths

John has a Ph.D. in Computer Science and is a professional software engineer and consultant, as well as a computer science university professor and department chair.

Covered Topics