Post by David WilkinsonBut I guess I am confused. I have always thought of what you call
"functional cast" as invoking the constructor.
When a functional cast expression has one parameter, it is exactly equivalent to a corresponding C-style cast. Yes, you can invoke a constructor using C-style cast:
class C {
public:
C(int);
};
C v = (C)42;
Post by David WilkinsonSo why exactly do
LPVOID p = LPVOID(n);
LPVOID p(LPVOID(n));
both work, while
LPVOID p = n;
LPVOID p(n);
do not?
Well, because the standard says so. I don't know the rationale behind this, but if I had to guess, I'd say the committee made functional cast and C-style cast behave the same in order to avoid the proliferation of similar but subtly different cast mechanisms.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925