- NEW!
Help answer this question below.
At the bottom line, pointers or references are used as aliases for an object or variable.
pointers or references may be used to pass parameters by reference: i.e. to pass the argument itself instead of its value. This allows functions to modify their passed arguments and return additional values, or to avoid copying the argument for efficiency purposes.
pointers or references must be used when the object itself has no identifier, for example, if it is dynamically created.
pointers or references to a less specific type must be used to take advantage of polymorphism: that feature of object-oriented languages that allows different objects to provide differing implementations of common functions.
Pointers and references differ in how they are created and accessed. References are created directly from the object or variable, pointers are created in a number of ways, but typically by using the & operator.
References are accessed as if they were the object or variable referred to, pointers must be dereferenced using the unary prefix * operator or the a->b operator which is equivilant to (*a).b
The destination of a pointer may be changed (point elsewhere).
The desitnation of a reference may not be changed, and must be known from the point the reference is created.
Pointers are therefore useful for dynamic structures where objects refer to other objects that may change. e.g. in structures such as linked lists and trees.
Write a program that is part of a payroll system 4 a very small store write d progm that does the tasks listed Workers are paid by the hour
by dwyanet on February 16th, 2011
| 1 person likes this
In a visual C++ WinForm application, how do I pass a variable from an event to another event?
by WickeTD on February 24th, 2011
| 1 person likes this
write a C program to input characters from the user until a blank is read. use while loop to find the no. of nonblank characters
by hira92 on October 24th, 2010
| 1 person likes this
A pointer variable can contain a pointer to a valid object, a pointer to a deleted object, NULL, or a random value.
by Patrick_M on October 18th, 2010
| 1 person likes this
c++ directx picking is not working
by fbixzramiz on November 22nd, 2010
| 1 person likes this
You're reading What is use of pointer in C++?
Comments