answersLogoWhite

0

Pointers are variables. They allow you to store memory addresses and to indirectly manipulate the contents of those memory addresses. Pointers can point to variables, constants and functions -- anything that resides in memory -- so long as the type of the pointer is covariant with the type being pointed at. Pointers that are no longer in use should be nullified by assigning the value NULL, thus preventing indirect access to memory that may no longer be in scope.

In C, a pointer is no different to a reference, hence we use the term 'dereference' when indirectly accessing the value of a pointer (the memory being pointed at). But in C++, a reference is not a variable of any kind, it is simply an alias that you can use in your source code to refer to an instance of an object, function, variable or constant. C++ references must be initialised at the point of instantiation, and are not unlike constant pointers. However, unlike references in C, references in C++ can never be NULL (a NULL reference will invalidate your program).

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

Difference between array and pointers in c plus plus?

A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.


What is pointer to an object in c plus plus?

A pointer is simply a variable that stores a memory address. Thus a pointer to an object is simply a variable that stores the memory address of an object. Since pointers are variables, they require memory of their own. Pointers may also be constant, which simply means you cannot change what they point to. Pointers can also be dereferenced to provide indirect access to the memory they point to -- hence they are known as pointers. However, unlike C, pointers are not the same as references. In C++, a reference is simply an alias for a memory address and requires no storage of its own.


Why pointer is callded jewel of c language?

a pointer is a derived data type in c. pointers are undoubtedly one of the most distinct and exciting features of c language.it has added power and flexibility to the language. *pointers are more efficient in handling arrays and tables. *pointer can be used to support dynamic memory management. *pointers reduce length and complexity of programs. *increase the execution speed and thus reduce the program execution time. by following character's real power of c lies in proper use of pointers. pointer is called the jewel of c-language.


Initialization of variables in namespace in C plus plus?

Is an important thing to do.


In C you use the concept of pointers whereas there are no pointers used in JAVA why?

Pointers in C are generally the thing that gives learners the most trouble. When C code is not written correctly with respect to pointer use, the resulting bugs can often be very difficult to find and correct. On the other hand, pointers are absolutely necessary in some cases.The designers of Java wanted to make programming easier and hence avoided adding pointers to the language. Java does have object references which accomplish much of what pointers accomplish albeit in a safer way.

Related Questions

What is the difference between c plus plus and java programming?

Java doesn't have pointers. C++ has pointers.


What is the difference between pointers in c and c plus plus?

Nothing.


Is it possibly to return an array of strings in a function without using pointers in C plus plus?

No.


What are the storage allocation in C plus plus?

They mostly deal with pointers and new operators in memory.


How do you write a reverse function in C plus plus without pointers?

You can either use references or you can simply return the result by value. Note that in C++, unlike C, references are not the same as pointers. C++ references are aliases, alternate names for existing objects, whereas pointers are just variables that may contain a memory address that can be dereferenced.


Do you have pointer concept in c plus plus language?

Yes. All string variables are pointers as are other arrays.


Difference between array and pointers in c plus plus?

A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.


What does multiplying a pointer by 5 in C plus plus mean How does it change the pointer's value?

Multiplication is yet another thing, what you should never do with pointers.


What is meant by passing function to another function in c plus plus?

Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.


What is stream pointer in c?

C does not have stream pointers.


What is pointer to an object in c plus plus?

A pointer is simply a variable that stores a memory address. Thus a pointer to an object is simply a variable that stores the memory address of an object. Since pointers are variables, they require memory of their own. Pointers may also be constant, which simply means you cannot change what they point to. Pointers can also be dereferenced to provide indirect access to the memory they point to -- hence they are known as pointers. However, unlike C, pointers are not the same as references. In C++, a reference is simply an alias for a memory address and requires no storage of its own.


Sample programs in c plus plus language using pointers?

#include int main (int argc, char **argv){int i;for (i=0; i