Listing 3 Illustrates an implicit user-defined conversion

// convert3.cpp
#include <iostream. h>

struct A
{
   double x;

   A(double d)
   {
      cout << "A::A(double)" << endl;
      x = d;
   }
};

void f(const A& a)
{
   cout << "f: "<< a.x << endl;
}

main()
{
   A a(1);
   f(a);
   f(2);
   return 0;
}

// Output:
A::A(double)
f: 1
A::A(double)
f:2

// End of File