Monday, April 4, 2011

pointer in c++

| Monday, April 4, 2011 | 0 comments

1. IntroductionEvery time we declare a variable, C / C + + will provide the memory allocation for each variable. The size of memory allocated varies depending on the type of data variables. For example, for integer 2 bytes, to float 4 bytes, and so on. So, we declare every variable has 2 attributes that address and value.2. Understanding PointersPointer (pointer variable) is a variable that contains the memory address of the other variables. Pointer is a low-level variables that can be used to refer to integer values, character, float, double, or single, and even other data types supported by the language C.
Ordinary variables, static in nature and certainly, while the pointers are dynamic and can be more flexible. Pointer variable which does not refer to any value means having a NULL value, and referred to as a dangling pointer because its value is not initialized and can not be predicted.3. Pointer DeclarationAs with other variables, pointer variables must be declared before use.General Form: tipe_data * nama_pointer;Example: int * value, char * letter;Declare a pointer variable using an * before the variable name, whereas to display the value pointed to by a pointer variable, also used operator * (asterisk). If you want to display the address of where to store the value pointed to by a pointer variable, use the operator & (ampersand mark).4. Operations on Pointers• Operation AssignmentA pointer variable as well as other variables, also may have surgeryassignment. The value of a pointer variable can be copied to another pointer variableOperator (&) in connection with the pointer is the operator that returns the memory address of operandnya.Contohnya:int y = 5; / * declaration of variable y * /int * yPtr; / * pointer variable declarations yPtr * /yPtr = &y; / * fill yPtr pointer variable with the address of the variable y * /

0 comments:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment

thank you for visiting my blog and comment here. I hope the commentary contains a comment which intend to build and repair. criticism and suggestions I gladly accept.

Popular Posts

 

Total Pageviews

stat

© Copyright 2010. http://programminghaha.blogspot.com . All rights reserved | http://programminghaha.blogspot.com is proudly powered by Blogger.com | Template by o-om.com - zoomtemplate.com