Given a class like this:
class Foo {
public:
Foo(int);
Foo(const Foo&);
Foo& operator=(int);
private:
// ...
};
Are these two lines exactly equivalent, or is there a subtle difference between them?
Foo f(42);
Foo f = 42;
Edit: I confused matters by making the Foo constructor "explicit" in the original question. I've removed that, but appreciate the answers.
I've also added declaration of a copy constructor, to make it clear that copying may not be a trivial operation.
What I really want to know is, according to the C++ standard, will "Foo f = 42" directly call the Foo(int) constructor, or is the copy constructor going to be called?
It looks like fasih.ahmed has the answer I was looking for (unless he's wrong).