0

I don't understan off a pointer c++😑😑😑😑😑

9th Feb 2017, 9:27 AM
Hmei27
Hmei27 - avatar
3 ответов
+ 4
Pointer is a variable that stores the address of another variable. Example : int *a; char *a; Where, * is used to denote that ''a'' is pointer variable and not a normal variable. In this context, the asterisk is not a multiplication Key points to remember about pointers: # Normal variable stores the value whereas pointer variable stores the address of the variable. # The content of the pointer always be a whole number i.e. address. # Always pointer is initialized to null, i.e. int *p = null. # The value of null pointer is 0. # & symbol is used to get the address of the variable. # * symbol is used to get the value of the variable that the pointer is pointing to. # If pointer is assigned to NULL, it means it is pointing to nothing. # Two pointers can be subtracted to know how many elements are available between these two pointers. # But, Pointer addition, multiplication, division are not allowed. # The size of any pointer is 2 byte (for 16 bit compiler). Since pointers only hold addresses, when we assign a value to a pointer, the value has to be an address. To get the address of a variable, we can use the address-of operator (&) Example program for pointer: #include <iostream> using namespace std; int main() { int *ptr, q;   q = 50;   /* address of q is assigned to ptr */   ptr = &q;   // prints address held in ptr, which is &q   cout << ptr;   /* display q's value using ptr variable */   cout << *ptr;   return 0; } sorry if I made a spell error...
9th Feb 2017, 11:31 AM
workneh Getie
workneh Getie - avatar
0
okay thanks
9th Feb 2017, 1:47 PM
Hmei27
Hmei27 - avatar
0
hallo Hmei27
23rd Mar 2017, 4:17 PM
Majedul haq
Majedul haq - avatar