Presentation is loading. Please wait.

Presentation is loading. Please wait.

References Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National.

Similar presentations


Presentation on theme: "References Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National."— Presentation transcript:

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


Download ppt "References Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National."

Similar presentations


Ads by Google