Oct 26 2022 Flashcards
Syntax of getting address of variable using pointers
&p
What is declaration of Pointer
*p
What is initialization of Pointer
p = &alpha
int *p;
p = &x
cout«_space;*p ;
what gets printed
The value of x
int p;
p = &x
cout«“p”;
what gets printed
The value of x
what does & do
Gets the address of the variable
what does * do in pointers
Declaration or Dereferencing
How is memory divided while your function is running
Stack , Heap , Stack
What section can main function access in the memory
Main Function and Stack
What is point of pointers
The main function needs pointer to access heap or file on a disk/printer/network connection/keyboard/mouse/monitor
Heap Memory is accessed dynamically
Size of Memory required in the heap is decided at runtime and not compile time
What is the difference between heap array and stack array while creation
The new keyword
When you use the new keyword you must you include and what is the syntax
pointer
1 -> int *p ;
p = new int[5]
2-> int *p = new int[5]
How it the effect of memory when it goes out of scope
Stack memory is deleted but heap memory is not deleted
How to delete an array in Heap
delete []p
p = null
The sequence is imp