Pointers Flashcards
What is a pointer
A variable;e that hold a memory address and not data like most variables
How to declare pointer
Using * before the pointers name
What is the revenue operation
& obtains a variables address. Returns the memory address
What is the derefrance operator
Retrieve the data to which the pointer points to
What is the new operator
Allocates memory for the given type and returns a pointer to the allocated memorY
Allocating for a type that is a class
The new operator calls the class’s constructor after allocating memory for the classes member variables
What is the member access operator
Allows access y]to the objects same as *
What is the delete operator
Dell Oates a block or memory, if pointer is null delete has no effect
What is a dangling pointer?
When the object that a pointer is pointing to gets deleted. That ends up with that -linter pointing to a deleted object
What’s a memory leak
When memory is in the head can’t be accessed. A pointer is moved but the addresses in memory was not correctly stored
What is static memory
Region where global variables and static local variables are allocated. Spastic variables are allocated once and stay in the same memory location
What is the stack
Region where functions local variables are allocated. Function call adds local va7]risk led to the stack and return removes them. Also called automatic memory
What is the heap
Region where the new operator allocated memory and where the delete operator deslocaresmemory. The region is also called free store