Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ Pointers Review. Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example.

Similar presentations


Presentation on theme: "C++ Pointers Review. Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example."— Presentation transcript:

1 C++ Pointers Review

2 Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example

3 What is a pointer  A pointer is essentially an address  It tells your code "manipulate whatever is 'here'"

4 Why do I care?  Pointers give the power to improve program memory usage and speed (no NEED to copy data)  Pointers let you 'return' more than one value from a function (direct manipulation of original)  Most languages DON'T have them. This is a reason C and C++ are so used.

5 What can be 'pointed to'?  Objects  Functions  Variables  Hardware (Wunderboard IO)

6 Example  int x = 5;  x is synonymous with 5  "The integer x" is as valid as "The integer 5"  int* y = &x;  y is a pointer to a memory location holding an integer  x is an integer and &x is the address of integer x  "Integer pointer y point to integer x"

7 Using pointers in Function Parameters  int someFunc(int value)  manipulating 'value' has no effect on the original  int someFunc(int *value)  manipulating 'value' modifies the original

8 In summary  Try to use pointers in your labs/assignments to gain experience  In 'real coding' pointers are not ALWAYS the answer


Download ppt "C++ Pointers Review. Overview  What is a pointer  Why do I care?  What can be 'pointed to'?  Example."

Similar presentations


Ads by Google