[interfacekit] Re: oddish?

On Mon, 16 Feb 2004, Adi Oanca wrote:

>     Have another question for you guys.
>
> class Layer
> {
> public:
> [...]
>       void            Invalidate(const BRegion &region);
> [...]
> }
>
> int main()
> {
> [...]
> lay->Invalidate(BRect(225,10,350,400));//BRegion(lay->Bounds()));
> [...]
> }
>
>
>     Why is this working? Why is there no compiler error?
>
> Does it have something to do with the fact that one BRegion constructor
> is declared like this:
>
>       BRegion(const BRect rect);
>
> ?

Yep, that's exactly the reason. It's a nice C++ feature. If undesired, one
can disable it by marking the constructor with the modifier `explicit'.

CU, Ingo

Other related posts: