cs31day14 Wk 7 W

cs31day14 Wk 7 W - Pointers the value of a pointer is...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Pointers the value of a pointer is essentially just the address of a value in memory. 1. Another way to implement passing by reference 2. Traverse arrays 3. Manipulate dynamic storage 4. Represent relationships in data structures PREVIOUS EXAMPLE: void polarToCartesian(double rho, double theta, double& xx, double& yy); int main() { double r; double angle; ... // get values for r and angle double x; double y; polarToCartesian(r, angle, x, y); ... double y2; polarToCartesian(r, angle, x, y2); .. } void polarToCartesian(double rho, double theta, double& xx, double& yy) { xx = rho * cos(theta); yy = rho * sin(theta); } ________________________________________________________________ ________________________________________ CHANGING THE EXAMPLE TO USE POINTERS USE THE STAR CHARACTER void polarToCartesian(double rho, double theta, double * xx, double * yy); int main() {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
double r; double angle; // x[15.6] ... // get values for r and angle // y[1.57] double x; double y; polarToCartesian(r, angle,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

cs31day14 Wk 7 W - Pointers the value of a pointer is...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online