#include <iostream>
using namespace std;
class Imp
{
public:
int X(int) {return 50;}
int Y(int y) {return y;}
};
int main()
{
Imp i;
cout << i.X(100) << endl;
return 0;
}
This code works and prints out 50. My question is what happens to the argument passed? Just out of curiosity. 🙂
The arguments for such parameters are passed in the usual way, but it is not possible to acess such parameters by name in the corresponding function definition (unusual machine architecture specific code can be written however to access the argument)
A good example is the postfix operator++ (and –) as well which is usually overloaded as
NB: The compiler usually passes a dummy argument 0 for such overloads
The dummy parameter type is indicated as ‘int’ and is not named almost always(and hence not used in the operator definition)