Files
Learn_Cpp/basics
2022-09-29 11:03:29 +02:00

99 lines
4.2 KiB
Plaintext

Objectoriented programming:
Code can be splitted into parts which can be reused again.
Introduces classes and structures, from which objects can
be created. Classes can contain functions which can be used
specifically on objects of that class, to edit them.
Makes it easier to administrate for example multiple soldiers,
by creating multiple soldier-objects of class soldier.
Standards:
Standards are used to unify software-modules, so they can be
used on all systems which are implementing those standards.
DIN -> Deutsches Institut fuer Normung
ANSI -> American National Standards Institute
STL -> Standard Template Library
C++:
C++ is a programming language used to programm. It is close to
the system, which means that it is possible to influence the
system in a very close way.
SDK -> Software Development Kit
Many SDKs are optimized for C++. It also implements a functionality
called pointers, which point to an address, where some data is
stored. They allow fast and efficient access on that data.
It is one of the most used programming languages to create games.
Preprocessor-commands:
At compiling of programm-code, those commands marked with a hash #
are processed first.
Includes:
Includes are preprocessor-commands which allow to include already
existing code into your project. For example the iostream library
contains code to read and write from and to console.
If you want to include libraries from the working-directory, you
have to use "lib" and the compiler will be looking there for the libs.
If you want to use libraries from a special directory, specified by
the include path of the compiler, you have to use <lib>.
Example: #include <iostream>
Namespaces:
Namespaces are named spaces, which can include functions and variables.
They can help to seperate different modules with equal function- or variable-
names. To use a function or variable of a specififc namespace use
namespace::variablename or namespace::functionname. Namespaces help to avoid
conflicts between modules which are programmed by different people.
main-function:
Every programm needs a main-function, which serves as the entrance-point of
the programm. The main-function returns 0 if there was no error, as default
we always return 0. The curled paranthesis {} mark the content of the function.
cout:
Function from library iostream at namespace std, which is used to print messages
to the console.
Example: cout << "Message" << endl;
endl stands for end of line.
Escape-signs:
Escape-signs are used to display some special characters like spaces, tabs, etc.
They can be used at strings (char-arrays) and are indicated by a backward-slash.
Examples:
\n -> Carriage Return
\t -> horizontal tab
\v -> vertical tab
\r -> return to beginning of collumn
\b -> jump back by one sign
\" -> insert "-sign
\\ -> insert backslash
\a -> plays signal-sound
Variables:
There are so called primitive datatypes and abstract datatypes. Abstract datatypes
are introduced with objectoriented programming in which objects are these abstract
datatypes. They are consisting out of primitive datatypes.
Primitive datatypes are numbers, characters or (void).
There are so called type qualifiers which influence the range of values and the
required memory to store the variable.
But be aware, that also the compiler on which C is used, influences the required
memory-usage.
List is for 32bit gcc
short int: 2 byte -32,768 to 32,767 %hd
unsigned short int: 2 byte 0 to 65,535 %hu
unsigned int: 4 byte 0 to 4,294,967,295 %u
int: 4 byte -2,147,483,648 to 2,147,483,647 %d
long int: 4 byte -2,147,483,648 to 2,147,483,647 %ld
unsigned long int: 4 byte 0 to 4,294,967,295 %lu
long long int: 8 byte -2^63 to 2^63-1 %lld
unsigned long long int: 8 byte 0 to 18,446,744,073,709,551,615 %llu
signed char: 1 byte -128 to 127 %c
unsigned char: 1 byte 0 to 255 %c
float: 4 byte 1.2E-38 to 3.4E+38 %f
double: 8 byte 1.7E-308 to 1.7E+308 %lf
long double: 16 byte 3.4E-4932 te 1.1E+4932 %Lf
with the sizeof()-function you can check the size with your compiler.