• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Monday, August 13, 2012

C++ - TUTORIAL POINTER


Hello friends.. welcome to my site at “We Are Knowledge”.. Did you find dekstop programming about C++ ??. If Yes.. you choosing the right site. Because in here you want getting many IT knowedge about it.

C++ id language programming based dekstop, and having self compiler not likely language programming cobol which requires other compiler.

Variable is a value stored in memory and can be accessed using the identifier. This variable is basically stored at an address in memory. And each memory address different from the others or can be called unique.


Address operator (&)

when declaring variables, the user does not have to specify the actual location in memory, because the compilers and operating systems perform automatically at run-time....
ampersand (&) is signs to know where the variables are stored

Ex:
hfae = &wak;


Operator Reference (*)

Directly we can access using a pointer and giving an asterisk (*) pointer to the identifier.

Ex:
hfae = *wak;

Syntax of Pointer declaration

type * pointer_name;


Initialization Pointer

The Type

float * greatnumber;
int * number;
char * character;


Ex:

int value;
int *tommy = &
value;


Pointer Arithmetic

to be found 3 (three) pointer:
short *myshort;
char *mychar;
long *mylong;


Void pointer

Void pointer type of a special type in the pointer. excess void pointers can point to any data type like as: integer, character or string, float weakness is not able to use the operator with an asterisk (*),


Pointer For functions

The primary use of the pointer function is to provide a function as a parameter to another function

Ok direct to program..

You can copy this coding and paste in your aplication likely “borland” or “turbo”

Example 1 :

#include <iostream.h>
#include <conio.h>
int main ()
{
 int value1 = 10, value2 = 20;
  int * try_pointer;
  try_pointer = &value1;
  *try_pointer = 10;
  try_pointer = &value2;
  *try_pointer = 20;
  cout << "value1 == " << value1 << endl << "value2 == " << value2;
  getch();
}


Press “alt  + F9” >> compile the program
Press “ctrl + F9” >> running the program


To result :

value1 == 10
value2 == 20



Ok just it…

I hope you understand with my article…
Thanks for visitors..
See you later

No comments:

Post a Comment