cs31day14 Wk 7 W

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

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

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() {

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

View Full Document
double r; double angle; // x[15.6] ... // get values for r and angle // y[1.57] double x; double y; polarToCartesian(r, angle,
This is the end of the preview. Sign up to access the rest of the document.

## 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
Ask a homework question - tutors are online