|
@@ -87,7 +87,7 @@ or use it in an arithmetic expression:
|
87
|
87
|
|
88
|
88
|
|
89
|
89
|
|
90
|
|
-### Overloaded functions
|
|
90
|
+### Overloaded Functions
|
91
|
91
|
|
92
|
92
|
Overloaded functions are functions that have the same name, but a different *signature*.
|
93
|
93
|
|
|
@@ -129,11 +129,11 @@ In that last example, the function `example` is overloaded since there are five
|
129
|
129
|
|
130
|
130
|
|
131
|
131
|
|
132
|
|
-### Default values
|
|
132
|
+### Default Values
|
133
|
133
|
|
134
|
134
|
Values by default can be assigned to the parameters of the functions starting from rightmost parameter. It is not necessary to initialize all of the parameters, but the ones that are initialized should be consecutive: parameters in between two parameters cannot be left uninitialized. This allows calling the function without having to send values in the positions that correspond to the initialized parameters.
|
135
|
135
|
|
136
|
|
-**Examples of function headers and valid function calls:**
|
|
136
|
+**Examples of Function Headers and Valid Function Calls:**
|
137
|
137
|
|
138
|
138
|
1. **Headers:** `int example(int var1, float var2, int var3 = 10)`
|
139
|
139
|
|
|
@@ -154,7 +154,7 @@ Values by default can be assigned to the parameters of the functions starting fr
|
154
|
154
|
c. `example(5)` In this function call only the first parameter is given a value, and the last two parameters will be assigned values by default. That is, `var1` will be 5, `var2` will be 5.0, and `var3` will be 10.
|
155
|
155
|
|
156
|
156
|
|
157
|
|
-**Example of a valid function header with invalid function calls:**
|
|
157
|
+**Example of a Valid Function Header with Invalid Function Calls:**
|
158
|
158
|
|
159
|
159
|
1. **Header:** `int example(int var1, float var2=5.0, int var3 = 10)`
|
160
|
160
|
|
|
@@ -165,7 +165,7 @@ Values by default can be assigned to the parameters of the functions starting fr
|
165
|
165
|
b. `example()` This function call is **invalid** because `var1` was not assigned a default value. A valid call to function `example` needs at least one argument (the first).
|
166
|
166
|
|
167
|
167
|
|
168
|
|
-**Examples of invalid function headers:**
|
|
168
|
+**Examples of Invalid Function Headers:**
|
169
|
169
|
|
170
|
170
|
1. `int example(int var1=1, float var2, int var3)` This header is invalid because the default values can only be assigned starting from the rightmost parameter.
|
171
|
171
|
|
|
@@ -176,7 +176,7 @@ Values by default can be assigned to the parameters of the functions starting fr
|
176
|
176
|
|
177
|
177
|
---
|
178
|
178
|
|
179
|
|
-## Parametric equations
|
|
179
|
+## Parametric Equations
|
180
|
180
|
|
181
|
181
|
*Parametric equations* allow us to represent a quantity as a function of one or more independent variables called *parameters*. In many occasions it is useful to represent curves using a set of parametric equations that express the coordinates of the points of the curve as functions of the parameters. For example, in your trigonometry course you should have studied that the equation of the circle of radius $$r$$ and centered at the origin has the following form:
|
182
|
182
|
|
|
@@ -239,11 +239,11 @@ To plot a curve that is described by parametric equations, we compute the $$x$$
|
239
|
239
|
---
|
240
|
240
|
|
241
|
241
|
|
242
|
|
-## Laboratory session:
|
|
242
|
+## Laboratory Session:
|
243
|
243
|
|
244
|
244
|
In the introduction to the topic of functions you saw that in mathematics and in some programming languages, a function cannot return more than one result. In this laboratory experience's exercises, you will practice how to use reference variables to obtain various results from a function.
|
245
|
245
|
|
246
|
|
-### Exercise 1: Difference between pass by value and pass by reference
|
|
246
|
+### Exercise 1: Difference between Pass by Value and Pass by Reference
|
247
|
247
|
|
248
|
248
|
|
249
|
249
|
**Instructions**
|
|
@@ -274,7 +274,7 @@ In the introduction to the topic of functions you saw that in mathematics and in
|
274
|
274
|
|
275
|
275
|
4. Execute the program and observe what is displayed in the window `Application Output`. Notice the difference between the content of the variables `argValue` and `argRef` despite the fact that both had the same initial value, and that `paramValue` and `paramRef` were assigned the same value. Explain why the content of `argValor` does not change, while the content of `argRef` changes from 0 to 1.
|
276
|
276
|
|
277
|
|
-### Exercise 2: Creation of an overloaded function
|
|
277
|
+### Exercise 2: Creation of an Overloaded Function
|
278
|
278
|
|
279
|
279
|
**Instructions**
|
280
|
280
|
|
|
@@ -313,7 +313,7 @@ In the introduction to the topic of functions you saw that in mathematics and in
|
313
|
313
|
|
314
|
314
|
2. Now you will create an overloaded function `circle` that receives as arguments the value of the angle $$t$$, the reference to the variables $$x$$ and $$y$$, and the value for the radius of the circle. Call the overloaded function `circle` that you just implemented from `main()` to calculate the values of the coordinates $$x$$ and $$y$$ for the circle with radius 15 and draw its graph. Graph the circle within the `wCircle` object. To do this, you must call the method functions `AddPointToGraph(x,y)`, `Plot` and `show` from `main()`. Remember that these should be preceded by `wCircle`, for example, `wCircle.show()`.
|
315
|
315
|
|
316
|
|
-### Exercise 3: Implement function to calculate the coordinates of the points in the graph of a curve
|
|
316
|
+### Exercise 3: Implement a Function to Calculate the Coordinates of the Points in the Graph of a Curve
|
317
|
317
|
|
318
|
318
|
**Instructions**
|
319
|
319
|
|