11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Calling a function by usingthe reference operatorChapter 14: Point and Stare at Objects 191The reference operator described in Chapter 9 works for user-definedobjects. The following PassObjRef demonstrates references to user-definedobjects:// PassObjRef - change the contents of an object in// a function by using a reference#include #include #include using namespace std;class Student{public:int semesterHours;float gpa;};// same as before, but this time using referencesvoid someFn(Student& refS){refS.semesterHours = 10;refS.gpa = 3.0;cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!