Test 1 Flashcards
(35 cards)
Size of char in bytes
One
Size of short in bytes
Two
Size of float in bytes
Four
Size of long in bytes
Four
Size of double in bytes
Eight
&
Address operator: accesses the variables memory location
Which byte of a variable contains the memory address?
The first one
By default, memory addresses print in what number type?
Hexadecimal
How to print an address in decimal
cout
A value that represents or holds the value of a memory location is
A pointer
Indirection operator
*
Declaration of a pointer
int ptr OR int ptr
To access the value of a variable using a pointer
ptr (ptr = 100; or cout
“*” can be used for
Multiplication, declaration of a pointer, and as the indirection operator (they’re not the same!!!)
Pointer notation
*(arrayName+1)
Array notation
Ptr[1]
How does pointer arithmetic work
It adds not 1 value, but one “amount of bytes” required for the type
Value to specify that a pointer is not being used/doesn’t point to a valid address
0
A pointer pointing to 0 is called a
NULL pointer
Use a pointer with cin
Cin»_space; *ptr;
A int *const ptr is:
A pointer whose address can’t change.
A pointer TO a const:
Can’t change the value at its memory location, but it’s memory address can change
To delete a dynamically allocated array:
Delete [] ptr;
Pointers that point to memory that has already been delete(d)
Dangling pointer