SYSC 2006 Lecture 6: Pointers and Functions

99 views1 pages

Document Summary

Function that is supposed to swap its arguments, but does not void swap (int x, int y) int temp; //auxiliary variable temp = x; x = y; y = temp; C does not support pass by reference which can solve this problem. C++ does, the parameter is changed to( int &x, int &y) Addresses as function arguments int a = 5, b = 10; swap (&a, &b); void swap(int *px, int *py) Buggy swap void swap(int *px, int *py) int temp; temp = *px;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents