Discussion 1: C++ Refresher Flashcards
preprocessor directives
top of file with a #, processed before the compiler, #include, #define, (#ifdef, #ifndef, #endif), #pragma once
include
include replaces the directive with the content of the specified header or file
define (
define replaces all instances of identifier with replacement.
ifdef, ifndef, and #endif
identifiers allows sections to be complied if an identifier is/isnt defined
pragma once
makes source file to be included only once in a single compilation
char
1 byte | primitive type
std::string( char array )
char array
int (How many bytes, range)
4 bytes | -2.147 bil - 2.147 bil
unsigned int (How many bytes, range)
4 bytes | 0 to 4.294 bil
long (how many bytes, range)
8 bytes | -910^18 to 910^18
unsigned long (bytes, range)
8 bytes | 0 to 18*10^18
double (bytes, use case)
8 bytes | used for decimals
float (bytes, use case)
4 bytes | used for decimals
float vs double
float uses 4 bytes , double uses 8 bytes.
Use case: double is more precise
bool
1 byte | True or False
void
0 bytes | function not returning anything
std::string( char array ) vs std::string
std::string(char array) is an array of characters while string is not
auto (keyword)
derives the type of a variable on the fly
decltype (keyword)
derives the type of variable by using another variable
pointers
variable whose value is the memory address of another variable
pointer (syntax)
*
Address-of Operator
& | gets the memory address of a variable
Dereference Operator
- | gets the value at the memory address of a pointer
pointer of array
points at the first element of the array