This is the situation:
int f(int a){
...
g(a);
...
}
void g(int a){...}
The problem is that the compiler says that there is no matching function for call to g(int&). It wants me to pass the variable by reference and g() recieves parameters by value.
How can I solve this?
Well, there's not much here, but the first thing is: make sure you have a declaration for g that's included before f is defined.
void g(int a);
Otherwise, when you get to f, function f has no idea what function g looks like, and you'll run into trouble. From what you've given so far, that's the best I can say.
您的函数g()
需要在f()
之上定义
There are two things wrong:
1) g is not declared before it is used, so the compiler will compain about that. Assuming you fixed that issue, then the next issue is:
2) f is not returning an int.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.