Polymorphism, virtual
Polymorphism, virtual
Polymorphism, virtual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
References and functions References are often used to pass an object toa function, or return an object from a function:● C only has call-by-value, so use pointers: int a = 5; void dbl_me(int* x) { (*x) *= 2; } dbl_me(&a);// pass a pointer● C++ allows call-by-reference: void dbl_me(int& x) { x *= 2; } dbl_me(a);// call-by-refCMPT166: polymorphism 30 Jan 200912