I got the code from here.
class Timer {
public:
Timer();
};
class TimeKeeper {
public:
TimeKeeper(const Timer& t);
int get_time()
{
return 1;
}
};
int main() {
TimeKeeper time_keeper(Timer());
return time_keeper.get_time();
}
From the looks of it, it should get compile error due to the line:
TimeKeeper time_keeper(Timer());
But it only happens if return time_keeper.get_time();
is present.
Why would this line even matter, the compiler would spot ambiguity on time_keeper(Timer() )
construction.