How to do it...

To declare explicit constructors and conversion operators (regardless of whether they are functions or function templates), use the explicit specifier in the declaration.

The following example shows both an explicit constructor and a converting operator:

    struct handle_t 
{
explicit handle_t(int const h) : handle(h) {}

explicit operator bool() const { return handle != 0; };
private:
int handle;
};
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset