You are on page 1of 2

384

C++: The Complete Reference

} void f(int &x) { cout << "In f(int &)\n"; }

As the comments in the program describe, two functions cannot be overloaded when the only difference is that one takes a reference parameter and the other takes a normal, call-by-value parameter. In this situation, the compiler has no way of knowing which version of the function is intended when it is called. Remember, there is no syntactical difference in the way that an argument is specified when it will be received by a reference parameter or by a value parameter.

C++

Chapter 15
Operator Overloading
385

You might also like