- Optimization technique.
- Use for compile time computation when function is called with constants
- Function is called a runtime with invoked with non-constants
- c++20
- Same as
constexpr
but required to be evaluated at compile time.
https://en.cppreference.com/w/cpp/language/type
- Use
std::string
over char lists (C strings). Safer to avoid buffer overflows. - You can turn a
std::string
(C++ string) into a C string withmyCppString.c_str()
Have the compiler infer the type
Used to define a type
- Use
std:vector
to declare a dynamic array andpush_back()
to add more elements and the array will be resized as needed.std::vector<int> someList(1); // init array with size of 1 someList[0] = 1; someList.push_back(2); // Use push_back to add more items and resize array at runtime
Basically each .cpp
file can be compiled separately to create .o
files
which can be linked together to create one executable.
g++ -c file1.cpp
: createsfile1.o
g++ -c file2.cpp
: createsfile2.o
g++ my_executable file1.o file2.o
: Links the files and creates the executable.
https://stackoverflow.com/a/10358977/5974855
https://github.com/MaskRay/ccls