Showing posts with label Pointer. Show all posts
Showing posts with label Pointer. Show all posts

Wednesday, October 12, 2011

Difference Between Constant Pointers and Pointer to Constants

1) Constant Pointers : These type of pointers are the one which cannot change address they are pointing to. This means that suppose there is a pointer which points to a variable (or stores the address of that variable). Now if we try to point the pointer to some other variable (or try to make the pointer store address of some other variable), then constant pointers are incapable of this.

A constant pointer is declared as : 'int *const ptr' ( the location of 'const' make the pointer 'ptr' as constant pointer)

2) Pointer to Constant : These type of pointers are the one which cannot change the value they are pointing to. This means they cannot change the value of the variable whose address they are holding.

A pointer to a constant is declared as : 'const int *ptr' (the location of 'const' makes the pointer 'ptr' as a pointer to constant.





If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Wednesday, May 18, 2011

Difference between Pointer and reference

In OOP like Java, guys often speak that there are no pointers but there are references. Here the reference or a reference pointers like as follows.
Dog d;
d.setName();

Here d is reference.
Actual concept of pointers is not implemented in Java due to the reasons like confusion and the hell caused by them.

However there are pointers in Java but in JCuda (Java bindings for the CUDA runtime and driver API) http://www.jcuda.de/jcuda/doc/index.html there is a class called jcuda.Pointer.