Topic: user conversions and cv-qualification


Author: mrice@quip.eecs.umich.edu (Michael Rice)
Date: 1995/06/01
Raw View
Example:

#include <iostream.h>

struct Converter {
  operator int()        { return 1; }
  operator const int()  { return 7; }
};

main()
{
  Converter A;
  // Converter B;

  int E = A;
  // const int F = B;

  cout << "E=" << E << endl;
  // cout << " F=" << F << endl;
}

According the the draft should this compile?  If so what would be the
output produced?  Are these two operators different enough?  What happens
when you uncomment the commented lines?

Compilers vary.  I am asking from an implementor's point of view, as
nobody would probably want to do this.