Learn to Code via Tutorials on Repl.it!

← Back to all posts
C++ FULL Begginners Course!
JustAWalrus (1181)

C++ FULL Beginners Course.

Hello, I am @Wuru and this is my C++ FULL Beginners Course.

I know @HahaYes 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 repl.it 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 repl.it 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>) 

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 <iostream> 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>) 

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!

CodingCactus (4118)

C++ FULL Beginners Course.


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.

Which one is it? You can't say it is a full beginners course if you don't teach beginners.

CuriousMonkey (44)

@CodingCactus you cant even talk you are just a noob who uses python and you do html and css but you dont even put the javascript u SUCK

CodingCactus (4118)

@CuriousMonkey erm you can't judge someone on what language they use

Kirit0 (23)

@CodingCactus yea that pretty ignorant ngl

xxpertHacker (785)

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.

Cough, each statement* must end with semi-colon.

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

I wish. Yeah no, they store ASCII. You're looking for u8'C'.

You didn't differentiate between types and classes. :/

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

Not true at all. C has strings. C has quote surrounded strings. C++ has the exact same strings.

auto x = "Hola, Mundo!"; // C-String

auto x = "Hola, Mundo!"s; // C++ std::string

auto x = "Hola, Mundo!"sv; // C++ string view (Preffered)

Also, C++ has two different function declaration syntaxes:
The one you mentioned, of course:

<return type> <name>(<args>)

And trailing return types:

auto <name>(<args>) noexcept(boolean) -> <return type>

Where the only thing required is the function name.

But seriously, you didn't explain much at all, this can't even teach a beginner.

JustAWalrus (1181)

Hey there buddy, if you care so much about beginners then why overwhelm them with this very rarely used stuff that they may never need. Okay, the ASCII instead of unicode argument. Fine, that is a solid point. But what beginner is going to use this other way to declare a function. And that is just an example. And for your other dumb rant going on about the semicolon thing, if you actually read instead of ranting on about it. You would see that I said that it needs to end in a semicolon or a bracket. A beginner wont know the terminology. They have no idea what a damn statement is. @xxpertHacker knows nothing about writing tutorials. Zip, Zilch, Nada. And that is not even the beginning of your rhetoric.

xxpertHacker (785)

@Wuru You said this is for people coming from other languages, not new programmer level beginners, that is whom I was referring to. Are you suggesting that one who knows C# to an intermediate level doesn't know what a statement is!? You have already assumed that they know what a variable is, but not a statement? That's nonsense. Those are both require bare minimum competence in programming with a C-family language. The only people that I could expect to have a problem with understanding this would be those coming from Python, which would still be very easy to explain to them. C++ isn't a beginner language, but what you have given couldn't even help someone set up a program on their own. You barely gave any explanation on the core of that which makes C++... well, C++.

JustAWalrus (1181)

I don't have the time to continue this pointless garbage so I will leave you with this: what I said is much easier to understand than the whole statement thing and also gets the same job done as the statement thing. @xxpertHacker

Kirit0 (23)

@JustAWalrus idk why people are bashing. It seems to work great for me, as my only known lang is python. So all these people who know more languages, who may i add wasnt the targeted audience, saying that your all wrong, you cant just go into something describing every little detail. the human brain dosnt proccess information fast enough to keep up with that in a total of 5 minutes of reading. so good job to you my dude

xxpertHacker (785)

@Kirit0 Explaining every last detail is the last thing you should do, I did most of that as a joke. But in truth, it's just that this doesn't teach anything at all. It gives a few examples, doesn't explain any of it, and walks away claiming to have taught you something. You can't begin learning C++ looking at this. I would legitimately recommend HaHaYes's C tutorials over this.

Kirit0 (23)

@xxpertHacker It taught me the equivalent of print and input from python into c++. Which tbh could be enough to make a very simple text based game. Me personally as the subjected audience found it to work well for how short it was. But i see you would have a different perspective based on your experience level though so

Kirit0 (23)

@xxpertHacker thanks for the recommendation though

xxpertHacker (785)

@Kirit0 It's that I believe that one should have a depth of understanding, this is super shallow. I don't think you need to know the finest details of stuff, but at least a moderate comprehension of what you're working with. Now if this were just the beginning and in the next tutorial he explained it in more depth showed alternative, explained what everything does, etc, then it would be far more acceptable.

But when you say it's intended for those who already know what programming is, that's when it's too shallow.

For example, does it explain why you do std::cin >> x; instead of std::cin << x; or std::cin(x);? What does << even do? That's one of the key features of C++, that needs to eventually be explained. No, it doesn't need to be a day one thing, but it should be pointed out.

honse (0)

tbh HahaYes's tutorials are kinda bad. ik @JustAWalrus's C++ tutorial isnt wonderful but ya gotta cut him some slack. He made tons of great tutorials that ive read before he left repl.it (i use this site to read tutorials) and this was kinda his last one (maybe he got burnt out or something) anyway, happy coding! @xxpertHacker

xxpertHacker (785)

@honse Good luck, I fully support trying to take whatever you can from a tutorial when you have the opportunity. It may not be great, but at least it's something. That goes to both HaHaYes, and JustAWalrus.

I'm actually going to go check out their ASM tutorials very soon and see if there's anything I can actually get out of them or apply to what I know.

Kookiez (348)

@xxpertHacker you mean HahaYes's C++ Tutorials, not C. I think it was CodeLongandPros who made the C one... IDK

xxpertHacker (785)

@OrangeJooce123 Oh yeah, it was, oops; I meant "C++" in that case.

Jakman (473)

I still rock with C.

DynamicSquid (4566)

@Jakman I've been doing C for a couple days now and it's actually kinda cool

Jakman (473)

@DynamicSquid Join us. We like it because of the few features. In cpp there are several solutions to a problem that could easily be solved with one only solution in C.

DynamicSquid (4566)

@Jakman yeah but that's why i like c++ since it gives you a lot of features to do something. you can really do whatever you want. like I have no problem writing code in c, but I wish it's had some features that c++ has, like templates

Jakman (473)

@DynamicSquid you can always make your own C compiler and give it whatever features you want.

programmeruser (529)

@Jakman I just tried C++ today (I usually use C) and it feels kind of easier to work with

Jakman (473)

@TheProgrammer3 yeah. I can get that. it has some nice features

HahaYes (1901)

I wonder how you managed to get 400 cycles... smh

firefish (937)

@HahaYes 1026 now, erm... HahaNo he can't do that? Aaaaaaaaaaaaaarghrgrhghrgrhgrhhrrhrhgrgrghrhrghrgrhrghrghrghrghrghrghrghrghrghrg,

liltaco (204)

Two very important parts of C++ you missed are the built-in STD types like std::vector, and the smart pointers like std::uniqueptr and std::sharedptr.

programmeruser (529)

I've been trying C++ and some parts seem kind of cleaner but C still has its advantages e.g. smaller, faster programs since it's more low level
Edit: http://www32.cplusplus.com/forum/lounge/265787/

Highwayman (1453)

Nooo C is NOT lower level why does everyone think this it’s ridiculous just because C++ is more feature-full does not mean that it has to be higher level!
Ugh. I’m sorry really if you are disturbed but this has got to stop why does everyone think this it’s starting to piss me off

DungeonMaster00 (170)

when will second part come out

JustAWalrus (1181)

Idk, I'm kind of quitting repl.it. @nk1rwc

DungeonMaster00 (170)

@Wuru bye then good luck i will remember you for you're good tutorials

HahaYes (1901)

smh what is this cycle squeezing tutorial

Wuru (41)

It's too long to be cycle squeezing. Please stop acting like you are the one to choose who has good tutorials and who doesn't. If you care so much about them, then please add by making your own better (in your view) tutorials rather than taking. Thank you :-) @HahaYes

xxpertHacker (785)

Ugh, .h files, in C++!?

firefish (937)

cough C course? coming soon? couch

HahaYes (1901)


JustAWalrus (1181)

Can we take this into some sort of DMs? And I will refrain from acting like you're "squeezing" even though I'm not. @HahaYes

CodeLongAndPros (1578)

@HahaYes Do you have any proof? Because that's serious.

JustAWalrus (1181)

His "proof" is that on my api section @zaraunderwood and @rileyhead have given me many cycles. I am not affiliated with them in any way. Maybe this is similar to when @Coder100 was given many cycles by a bot account? @CodeLongAndPros

CodeLongAndPros (1578)

@Wuru Strange, as they both have no code, no bios, no pfps, nothing.

JustAWalrus (1181)

Yeah, I have no idea who they are. This has happened to me before. I am affiliated with some weird friends who read my tutorials. Maybe they did this? @CodeLongAndPros

CodeLongAndPros (1578)

@Wuru They appear to be a bot account.

JustAWalrus (1181)

Hm, can they rollback my account? I would hate to lose all I've done in the past months because some low-lifes decided to bot-upvote my account. @CodeLongAndPros

HahaYes (1901)

@CodeLongAndPros yes thats a serious allegation. @zaraunderwood seems to be a direct copy of @saraunderwood whose account should be deleted

CodeLongAndPros (1578)

@HahaYes Their account saunder was deleted.

JustAWalrus (1181)

What should I do in this mess? I mean how can I help the investigation and or prove my innocence? @CodeLongAndPros

CodeLongAndPros (1578)

@Wuru You can't prove a negative, so I don't really know.

CodeLongAndPros (1578)

@Wuru You've also been warned for having alts last month as well.

JustAWalrus (1181)

Those weren't mine. I got warned without anyone hearing me out. @CodeLongAndPros

CodeLongAndPros (1578)

@Wuru So you did not create the accounts SarahHeisnoran, Verbix, FallenAngel3?

k9chelsea2 (768)

well repl.it team itself has said it has dealt with wurus "alts" no-one in the community knows for sure.

firefish (937)

@Wuru We will give you the benefit of the doubt........ for now.

HahaYes (1901)

@firefish you have safety. But ONLY FOR NOW