I have built the following minimal example:
class A
{
public:
A(const char *s);
private:
const char *p;
};
A::A(const char *s)
:
For 1), false
is of type bool
, and it can be promoted to an int
implicitely:
- the type
bool
can be converted toint
with the valuefalse
becoming 0
andtrue
becoming1
.
So, false
is basically promoted to NULL
/0
(or nullptr
), which can be assigned to a pointer.
For 2), §4.10 states that:
A null pointer constant is an integer literal (2.14.2) with value zero or a prvalue of type std::nullptr_t.
A null pointer constant can be converted to a pointer type; [...]
Only a Null pointer constant
can be converted to a pointer, and a null pointer constant is either an intergral with value 0
or std::nullptr_t
. true
(or 1
for that matter) aren't specified, and thus they can't be converted to a pointer.