Download presentation
Presentation is loading. Please wait.
1
References Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng Kung University Last updated: 3 November 2004 Chapter 9
2
Introduction Reference An alias Ex 9-1 Reference operator & Convention of naming Reference must be initialized C++ gives you no way to access the address of the reference itself because it is not meaningful, as it would be if you were using a pointer or other variable Using the address of operator & on references Ex9-2 Ex9-3 Null pointers and Null references
3
Passing function arguments by reference Limitations of functions Passing arguments by values Return only one value Overcome Using pointers Using references Ex 9-5: passing by value Ex 9-6: using pointers Ex 9-7: using references Understanding function headers and prototypes Ex 9-8: returning multiple values by pointers Ex 9-9: returning multiple values by references Ex 9-10: Passing by reference for efficiency Ex 9-11: Passing a const pointer
4
Important concepts C++ prefer references to pointers Cleaner and easier to use Better for hiding information Shortcomings of references Cannot be reassigned Cannot be null Where to put the reference or indirection operator
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.