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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents