Pointer in c++ part1

3,003 views
2,854 views

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,003
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
290
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Pointer in c++ part1

  1. 1. Author – Subhasis Nayak
  2. 2.  A pointer is a variable that holds a memory address. That’s it.  This is what the difference in between variable and pointer. ◦ Pointer holds the address ◦ Variable holds the value.
  3. 3.  Computer memory is divided into sequentially numbered memory locations. Each variable is located at a unique location in memory, known as its address. Memory representation
  4. 4.  Thecapability to use pointers and manipulate memory at a low level is one of the factors that makes C++ the language of choice for embedded and real-time applications.
  5. 5.  Different computers number this memory using different complex schemes.  We must happy, as a programmer, We don’t need to know the particular address of any given variable because the compiler handles the details.  If we want this information, though, you can use the address-of operator (&), which returns the address of an object in memory.
  6. 6.  It is so simple to declare a pointer. We need the type of the pointer  Next the name of the pointer.  When we declare a pointer variable such as pointer, the compiler sets aside enough memory to hold an address int *pointer;
  7. 7.  A pointer that is not initialized is called a wild pointer because you have no idea what it is pointing to.  If you want to initialize you can as like we do for variable. int *intPointer = 0;  A pointer whose value is zero is called a null pointer.  All pointers, when they are created, should be initialized to something.
  8. 8.  Every variable has an address. Even without knowing the specific address, you can store a variable’s address in a pointer. Declaring pointer Passing address
  9. 9. Holds the value Holds the address
  10. 10.  Type must be same to the variable whose address is going to pass to the pointer.  When you want to pass the address of the variable use (&) before the variable name.  When you want to pass the value use (*) before the pointer.

×