T
thell123
I want to call a function by call-by-reference, it's set/get functions
in another module/file, and I don't want public variables, but get an
error when I want to read the value with & :
error: call of overloaded 'Private_var(int&)' is ambiguous
note: candidates are void Private_var(int)
note: candidates are void Private_var(int&)
How should I call the get function ?
My code :
int my_private_var;
void Private_var(int var);
void Private_var(int& var);
void main()
int a=5;
int b=0;
Private_var(a);
// getting the private variable
Private_var((int&)b);
}
void Private_var(int var) {
my_private_var = var;
}
void Private_var(int& var) {
var = my_private_var;
}
in another module/file, and I don't want public variables, but get an
error when I want to read the value with & :
error: call of overloaded 'Private_var(int&)' is ambiguous
note: candidates are void Private_var(int)
note: candidates are void Private_var(int&)
How should I call the get function ?
My code :
int my_private_var;
void Private_var(int var);
void Private_var(int& var);
void main()
int a=5;
int b=0;
Private_var(a);
// getting the private variable
Private_var((int&)b);
}
void Private_var(int var) {
my_private_var = var;
}
void Private_var(int& var) {
var = my_private_var;
}