Pointers and Dynamic Memory Allocation. Declaring a pointer

  • View
    220

  • Download
    2

Embed Size (px)

Text of Pointers and Dynamic Memory Allocation. Declaring a pointer

PowerPoint Presentation

Pointers and Dynamic Memory AllocationDeclaring a pointer

Declaring a pointer

int* p;orint *p;string* q;pointer operations&- Address of operator*- Contents of operatorUsing the & operator

X=25 X= 30 X= 35X=40

PointersPointersPowerful feature of the C++ languageOne of the most difficult to masterEssential for construction of interesting data structures8Addresses and PointersC++ allows two ways of accessing variablesName (C++ keeps track of the address of the first location allocated to the variable)Address/Pointer Symbol & gets the address of the variable that follows itAddresses/Pointers can be displayed by the cout statementAddresses displayed in HEXADECIMAL9Example#include main( ){ int data = 100; float value = 56.47; cout

View more >