Download presentation
Presentation is loading. Please wait.
Published byKory Gilbert Modified over 9 years ago
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.