Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

C++ FULL Begginners Course!


C++ FULL Beginners Course.

Hello, I am

and this is my C++ FULL Beginners Course.

I know

already did one but I wanted to do a more in-depth anti-cycle-squeezing one.


This course is accelerated. Meaning it is meant for C#, C, Python, Java, etc. devs and will not teach you what a variable is for example. It will teach you how to make one though.

So let us begin.

Table of contents.

  • Why C++?
  • Setup
  • Quick comment overview
  • 1: Overview of a basic C++ file
  • 2: Hello, World!
  • Basic data types
  • 3: Variables
  • 4: Getting user input.
  • 5: Functions in C++
  • 6: IF Statement
  • 7: WHILE Loop
  • 8: FOR Loop
  • OOP Terminology
  • 9: In-depth OOP
  • 10: Structs
  • 11: Pointers
  • 12: .h files
  • Falts of C++
  • Where to go from here.
  • Conclusion
  • Bibliography

Why C++?

Pretend C is like a muscular guy who also happens to not be terribly bright.

C++ is like his nerdy but still muscular brother.

Still very strong and fast but not a pain to work with and more controlable.

C++ was invented by Bjarne Stroustrup in 1979 at Bell Labs as an extension to the C programming language.

He wanted an efficient, fast, and flexible language that was similar to C that also provided high-level features to organize your program.

Many languages are based off of C++ so it's a nice language to learn.


For your setup I would reccomend having the repl for this course open and checking out the C++ files there and trying to run them. For this I made it so you can run it and a bash script will execute that will prompt you which file you want to execute and run that file.

Anyway, use for now.

Quick comment overview.

This is just so that you understand when in the course I am using a comment.

A 1-line comment is used by putting a // before the comment.

// This is a one line comment.

A multi-line comment can be made by putting a /* at the start and a */ at the end a end of the comment.

/* This is a multi-line comment. Cool huh? */

Overview of a basic C++ file.

This section is going to use the 1.cpp file in the course repl.

This is the most basic of C++ files:

int main() { return 0; }

And all it does is end the program with an exit code of 0.

To see this exit code in go over to your side terminal and (after your code is done running) type echo $? to see the exit code of the last run program.

Let's break down the code.

int main() { }

Above is the main function. Your program needs one to run. It is called in the executable that your compiler will generate.

Functions in c++ have this syntax:

<return type> <name>(<args>) { <code> }

You can also put the first bracket next to the last paren like shown in the main function example.

The return type is what the data type is that the function returns.

The name is always alphanumeric but the first character can only be alphabetical it also cannot be a reserved keyword like int.

The args don't matter for this section.

And the code is where your code inside the function goes.

The return is seen in many langauges. We are returning an int like said in the return-type.

We return a 0.

And each line of code in c++ must end with either a semicolon or bracket. In the case of regular code it must end in a semicolon.

1: Hello, World!

This section is going to use the 2.cpp file in the course repl.

To print text to the screen we must use a library called iostream.

To include libraries from the standard c++ library set in our code we can do:

#include <libname>

In this case we do:

#include <iostream>

This is known as a preprocessor and we will use more of these later.

Then we define our main function:

#include <iostream> int main() { return 0; }

Then in that function we can type our line of code to print:

#include <iostream> int main() { std::cout << "Hello, World!\n"; return 0; }

Let's break the print down.

std is a container that happens to hold cout. std is known as a namespace.

We then put :: to tell C++ that we are refering to something in that namespace.

Then we put cout to tell c++ we want to use cout.

Then we put << because that is couts syntax.

We seperate our different things to print like this.

Then we put our hello world with a newline.

And lastly, our semicolon.

We run and get this output:

Hello, World!

Data types

C++ is statically typed meaning that once you declare a variable you cannot change its type.

C++ has way too many data types for us to talk about right now.

We will discuss a few and their different properties.


Chars have 's around them and they are a single unicode character.


Strings need to be included via #include <string> and they have "s around them they store multiple char types.


Ints are integers.


A double type variable is a 64-bit floating data type.


This section is going to use the 3.cpp file in the course repl.

To declare a variable we use this syntax:

<type> <name> = <value>;

The type is pretty straightforward.

Here are the identifiers for the types we discussed last section.

  • String - std::string
  • Int - int
  • Char - char
  • Double - double

The naming protocol is the same as for the functions.

The value is also easy.

Check out 3.cpp for a few examples.

Declaring a variable without an immidiate value.

We can use the syntax:

<type> <name>;

You cannot use this variable yet though.

Getting user input.

Short section but still important.

To get user input we type this:

std::cin >> <var>;

We have the same general idea as cout. We have our std:: and our name (in this case cin) then instead of <<s we put >>s and then we put the name of the variable we want the user input to go to.

We also have to include again.

Check 4.cpp for more details.

Functions in C++

So far the only function we have worked with has been the main() function.

Functions are like little containers of code.

<return type> <name>(<args>) { <code> }

That is the syntax for a function in C++.

So we have discussed data types in c++. The return type can be any of these.

It can also be a secret type.

This type is called void.

This means that the function returns nothing.

Lets declare a function together!

char giveBackChar(char x) { return x; }

Hopefully your functions will be more useful.

Check 5.cpp for more info.


Hey, so I'm making this a two-parter. This is part 1 and part 2 will come out soon!

2 years ago
You are viewing a single comment. View All