Sams Teach Yourself C++ in 21 Days

(singke) #1
Special Classes and Functions 519

47: fQuit = true;^15
48: break;
49: }
50: }
51: return 0;
52: }
53:
54: void PrintVals(int x, int y)
55: {
56: cout << “x: “ << x << “ y: “ << y << endl;
57: }
58:
59: void Square (int & rX, int & rY)
60: {
61: rX *= rX;
62: rY *= rY;
63: }
64:
65: void Cube (int & rX, int & rY)
66: {
67: int tmp;
68:
69: tmp = rX;
70: rX *= rX;
71: rX = rX * tmp;
72:
73: tmp = rY;
74: rY *= rY;
75: rY = rY * tmp;
76: }
77:
78: void Swap(int & rX, int & rY)
79: {
80: int temp;
81: temp = rX;
82: rX = rY;
83: rY = temp;
84: }
85:
86: void GetVals (int & rValOne, int & rValTwo)
87: {
88: cout << “New value for ValOne: “;
89: cin >> rValOne;
90: cout << “New value for ValTwo: “;
91: cin >> rValTwo;
92: }

LISTING15.6 continued

Free download pdf