I'm writing this because I am not sure how to approach the subject of pointers. In the book I am using to learn the fundamentals of C++ from, "C++ without fear" by Brian Overland, I had reached the sixth chapter which focuses on pointers.
I have so far found that the explanation of what pointers do to be rather vague, and I am finding myself questioning both the usefulness, and the functions of pointers in c++.
So far all I have really ascertained is that pointers are a syntax system (if you'll call it that) that is rather distinctively a part of c++, and some other languages I'm sure. What I understand so far is that they basically point to the address of a variable stored on the pc, and that these addresses are organized by means of hexadecimal placement, or what-have-you. I have learned the basic use for them, such as *p = x, &a, *p=&a, etc... Whereby of course, the & generally means "the address of" and * would mean something like "this variable points to...", or so it is explained in my book.
I have also learned that they are basically used to change the arguments of functions, and can be used interchangeably by other functions to change the arguments of that very function, or that of other functions. In that sense, they make a program more dynamic.
However, the only example I have been given thus far is of a program using a function that changes the arguments of another function in order to sort an array's information from least to greatest.
To be honest, it's not that I am finding it hard to comprehend the algorithm of pointers, I am just failing to see their practical importance, or how they can be used to really affect a program.
Without delving too deeply into programming algorithm or syntax that I wouldn't understand, could anyone kindly try to elaborate on the concept of pointers, how they may be used and why, as well as giving perhaps even a better definition for what the (&, and *) symbols could be characterized by? (These "names" given to symbols help me remember them and their functions, so a better example would be great.)
Question
Ryuurei
Hello.
I'm writing this because I am not sure how to approach the subject of pointers. In the book I am using to learn the fundamentals of C++ from, "C++ without fear" by Brian Overland, I had reached the sixth chapter which focuses on pointers.
I have so far found that the explanation of what pointers do to be rather vague, and I am finding myself questioning both the usefulness, and the functions of pointers in c++.
So far all I have really ascertained is that pointers are a syntax system (if you'll call it that) that is rather distinctively a part of c++, and some other languages I'm sure. What I understand so far is that they basically point to the address of a variable stored on the pc, and that these addresses are organized by means of hexadecimal placement, or what-have-you. I have learned the basic use for them, such as *p = x, &a, *p=&a, etc... Whereby of course, the & generally means "the address of" and * would mean something like "this variable points to...", or so it is explained in my book.
I have also learned that they are basically used to change the arguments of functions, and can be used interchangeably by other functions to change the arguments of that very function, or that of other functions. In that sense, they make a program more dynamic.
However, the only example I have been given thus far is of a program using a function that changes the arguments of another function in order to sort an array's information from least to greatest.
To be honest, it's not that I am finding it hard to comprehend the algorithm of pointers, I am just failing to see their practical importance, or how they can be used to really affect a program.
Without delving too deeply into programming algorithm or syntax that I wouldn't understand, could anyone kindly try to elaborate on the concept of pointers, how they may be used and why, as well as giving perhaps even a better definition for what the (&, and *) symbols could be characterized by? (These "names" given to symbols help me remember them and their functions, so a better example would be great.)
Thanks in advance,
Sincerely, Ryuurei.
Link to comment
Share on other sites
12 answers to this question
Recommended Posts