class A{
};
class B{
public:
B();
B(const &A);
};
void foo(A &a){
}
int main(){
B b;
foo(b); //error: invalid initialization of reference of type ‘A&’ from expression of type ‘B’
return 0;
}
In the above code, I have a compilation error
error: invalid initialization of reference of type ‘A&’ from expression of type ‘B’
The error can be solved by function overloading of foo(). However,do you have any other suggestion how I can solve the problem?
function foo(A &a) does not use parameter "a" as input. parameter "a" is simply the output of the function foo(A &a).
thanks.