C++ Flashcards
Pointer to constant data
const int * a; int const * a;
Pointer with constant memory address
int * const a = 0xFFFFFFFF;
Pointer to constant data and constant address
const int * const a = 0xFF; int const * const a = 0xFF;
In-line IF (conditional operator)
condition ? trueResult : falseResult
Comma Operator
a = (b=3, b+2); -> b=3; a=b+2;
Function Pointer
int (*fn)(int,int)
Operator Overloading
ReturnType operator + (OperandType);
ReturnType ClassName::operator+ (OperandType x) { }
static Class Members
Shared by all instances of the class
friend Functions
These are allowed to have access to private and protected class members
friend Class
These are allowed to have access to private and protected class members
What are not inherited?
constructor, destructor, operator overloads, friends
Inheritence Syntax
class X: public Y, public Z {}
virtual Members
Class member that can be redefined in child classes
Templates
template functionOrClass;
dynamic_cast
Cast of pointer from dervied to base class, checks that the object will be compatible
static_cast
Cast between derived and base classes, no check that the object is compatible
reinterpret_cast
Cast of pointers of any type
const_cast
Adds or removes ‘const’ keyword from a pointer
Memory allocation on the stack
alloca