Skip to content
Permalink
269d8df94e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
71 lines (50 sloc) 2.18 KB

CPP-Cheatsheet

for the boys, for the boys

Hello and welcome to the beginning of my C++ Cheatsheet; think of this as my Christmas present.
Through this, I figured it would be a great idea to have a centralised area for anything related to C++
that would have otherwise flown over your heads during a lecture.

Remember that I am always going to be here to help and 
will continue to work on this as the degree continues.

main.cpp:

First and Foremost, lets establish the elephant in the room, 
the one thing that every Programmer learns how to do
(write Hello World to the Console)

The way in which it works can go a variety of ways.
Since C++ is often referred to as a superset of C, 
it uses a lot of the C syntax as well as some of it's own libraries 

NOTE:

#include <iostream> is specific to C++ only

Due to this cross-compatibility, that means that libraries such as "stdio.h" and "stdint.h" 
can be used in both C/C++ programs

The use of the <iostream> library is the way that C++ declares standard input and output.
The thing that provides this library with the distinction with C libraries of 
a similar nature is that C++ uses specific keywords to handle various 
char oriented tasks such as cout for character output and cin for character input

Another way of writing "Hello World" to the Console is through using 
the namespace std as demonstrated below.

There is not really much distinction between this and the previous example
other than the fact that you are eradicating any reason to include std::cout.
Instead in it's place, you are declaring when the comsole stops writing
that line which the previous example does anyway.

In most base cases, you would only ever have to declare using this namespace if you 
plan on using any of the pre-requisite namespaces the libraries has such as
std::string, std::getchar, and std::int32_t - just to name a few examples