C++ Tutorial: Day 1
h
HahaYes (1221)

HahaYes' Very Good C++ Tutorial

So what is C++?

C++ is a general purpose programming language that is basically based off of C

It was created by Bjarne Stroustrup, and C++ is known as "C with Classes"

Quick Notes:

C++ is a statically typed language, which means that you have to declare if a variable is
a float, or a char, or a number. (Will elaborate on Day 2 or 3)

C++ is kinda a hard language, so there will be many chapters of this "series"
HahayEs

C++ is a FAST language, which makes it great for coding games, making software, and sending
stuff to space! (and fast food) yum yum

2nd fastest language (if you don't count machine code)

Each instruction in C++ MUST end with a semicolon


Alright! Day 1 of how many days of C++ Bootcamp!

A simple "Hello World" program in C++

#include <iostream>
// this is a comment
using namespace std; 
int main()
{
	cout << "Hello World" << endl;
	return 0;
}

The #include <iostream> is what we call a header. C++ allows a bunch of headers,
but because I'm lazy, I use #include <bits/stc++.h> because it basically is a header file that
has every standard library, including #include <iostream>

(C++ ignores blank lines btw)

The // symbol: the C++ version of a comment. A comment will not be executed.

The using namespace std; using namespace std means that you are going to use classes or functions (if any) from "std" namespace, so you don't have to explicitly call the namespace to access them.
Some people say that using namespace std; will become a bad habit, but I don't really see anything good or bad about it.

For example, if you don't have using namespace std; this is what you have to do to make a "hello world" prompt.

#include <bits/stdc++.h>
// this is a comment
using namespace std;
int main()
{
	std::cout << "Hello World" << endl;
	return 0;
}

(C++ also ignores tabs and spaces, but tabs and spaces help your code look cleaner)

The int main() is used as the "entry point" of a program. (Someone please help me elaborate on this)

The brackets, {} is where the program will be executed. (Not the French Revolution type, but like computer programming type.)
These brackets indicate the beginning and the end of a function.

What does cout << "" << endl; do?
well, cout basically is how the computer will display the output, and the quotation marks ("") are where you put in your characters. endl; tells the computer to create a new line. But, I prefer to use "\n" because it is a better way to create a new line.

The << is a symbol for output, and >> is the symbol for input.

The return 0; is basically the "exit" of a function, signaling that the program has ended.
(0 can be replaced with -1 or 1, but that is slightly more advanced, and I will cover that at a later date.)

That's it for Day 1!

Please upvote!

I cannot confirm that I can do daily tutorials, but I will try my best to upload one by 12:00 in the morning NYC time.

Any typos that need to be changed or suggestions are very welcome.

Thanks! HahaYes

EDIT: Day 2 COMING SOON

You are viewing a single comment. View All