menu

Intro to C++

An imperative, object-oriented, and generic programming language

Cygwin • Mingw • CLion
GroupType namesSize/precision
Character typeschar1 byte, at least 8 bits
char16_tat least 16 bits
char32_tat least 32 bits
wchar_tcan represent largest supported character set
Integer types (signed/unsigned)charat least 8 bits
shortat least 16 bits
intat least 16 bits; no smaller than short
longat least 32 bits
long longat least 64 bits
Floating-point typesfloat
doubleprecision not less than float
long doubleprecision not less than double
Boolean typebool
Null pointerdecltype(nullptr)
* In C++, type deduction also exists. The auto type will try to match the variable type with its value accordingly, and decltype(foo) bar will create 'bar' with the same type as 'foo'.
Syntax
KeywordMeaning
std::coutscope operator; shows that the method on the right side is under the namespace on the left.
Note that if we want to use a default namespace, we may define "using namespace std" to avoid it for all std methods.
std::cout << "Hello World!"insertion; sends string to cout
The Basics
Here is a sample that shows the structure of a class and how static methods work.
basics.java does not exist in the code directory