In the book Effective C++, Item 27
class Widget {
public:
explicit Widget(int size);
...
};
void doSomeWork(const Widget& w);
doSomeWork(Widget(15)); // create Widget from int
// with function-style cast
I'm not sure exactly what is happening when doSomeWork is called. I think the parameter w of function doSomeWork is initialized by another Widget object using copy constructor, but where is the other Widget object? Is it a temporary object created by casting as indicated by the comments? Can anyone tell me in details what have been called when doSomeWork function parameter is initialized?