SoftOver
 
Recommended


User login


 

Boolish Point

   

The code below is a valid C++. Why?

#include <stdio.h>

struct A
{
  A(bool) {}
};

class B{};

void print(const A&)
{
  printf("Boolish Ball...\n");
}


int main()
{
  B * p;
  print(p);
}

Explanation:

print() takes an argument of a type that is implicitly constructable from bool, and pointer is convertible to bool.

ALERT! Guideline: Avoid implicit conversion constructors.