To enable passing by reference, all you need to do is to change the METHOD SIGNATURE. For example, you have a function:
void foo(int bar)
The bar is passed by value. Now if you want to change it to pass by reference, all you need to do is to change the signature to:
void foo(int &bar) // notice the &
There's no need to change the function body.
Now, let's talk about your program. First of all, you don't need to pass by reference here. Usually we use reference in the following 2 scenarios:
a) We're passing a custom data type (like struct or class)
b) We want to change the data
In your case, float is a built-in type, and it doesn't looks like you want to change the passed-in MageN value.
Secondly, if you insist to use reference, change the method like this:
1 2 3
|
void setMage(const float &MageN) {
Mage = MageN;
}
|