In C++, if a class has a constructor which can be called with a single argument, then this constructor becomes conversion constructor because such a constructor allows automatic conversion to the class being constructed.
```
#include <iostream>
using namespace std;
class Y {
int a, b;
public:
Y(int i) { };
Y(const char* n, int j = 0) { };
};
void add(Y) { };
int main() {
// equivalent to obj1 = Y(2)
Y obj1 = 2;
// equivalent to obj2 = Y("somestring",0)
Y obj2 = "somestring";
// equivalent to obj1 = Y(10)
obj1 = 10;
// equivalent to add(Y(5))
add(5);
}
```
We can avoid such implicit conversions as these may lead to unexpected results. We can make the constructor explicit with the help of an explicit keyword.
```
class Y {
int a, b;
public:
explicit Y(int i) { };
explicit Y(const char* n, int j = 0) { };
};
```