- Nov 6, 2004
- 324
- 0
- 0
Hi, I am very much a beginner in terms of programming. The bulk of any education in regard to this has been Java based, but I have taken a course on C++ and am about to enter a computer science program. These courses were focused on familiarizing students with the language and teaching OOP concepts. There was little in the way of actual computer science discussed (for example, not much was said about what was going on under the hood. It was all very much high level).
So I am somewhat confused about pointers as used in C++. I understand what they are, but to the beginner, they can sometimes make code appear confusing and are difficult to follow (I emphasize in the case of the beginner). It is possible my understanding of pointers is misguided, so please indulge me on the following questions.
My questions:
1. Why use pointers to manipulate variables or attributes of objects instead of doing so directly? Wouldn't it be easier to just call the setters or getters of the objects?
2. Are there certain programming situations in which pointers are preferable?
Thanks in advance
So I am somewhat confused about pointers as used in C++. I understand what they are, but to the beginner, they can sometimes make code appear confusing and are difficult to follow (I emphasize in the case of the beginner). It is possible my understanding of pointers is misguided, so please indulge me on the following questions.
My questions:
1. Why use pointers to manipulate variables or attributes of objects instead of doing so directly? Wouldn't it be easier to just call the setters or getters of the objects?
2. Are there certain programming situations in which pointers are preferable?
Thanks in advance
