0

Why ia pointers and variable address important in cpp

13th Dec 2017, 4:55 PM
Vignesh
2 odpowiedzi
+ 7
Pointers are like the table of contents (or index) of a book. They're quick to look up, move around and access -- and they get you to the content you want without having to scan all the content (read every page) just to find it. To efficiently find interesting information in the book, you need to know the address (here, page number) of the content where your reference is pointing. Index (references / pointers) Bicycles ...... 2 Automobiles ...... 17 &17 (values on page, address=17) Automobiles first gained popularity when... See? Right to the content. Also... it tends to be more wasteful to move chapters (values) around, but maybe you're writing the book (or you're an editor) so you need content addresses for that stuff too. Move content to another page, the pointer should go along (or the value of your 'reference' is effectively lost) Pointers : references to things of value Pointed-at-addresses: values
13th Dec 2017, 5:20 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Great analogy, Kirk!
16th Dec 2017, 6:45 AM
Dipti Muni
Dipti Muni - avatar