Article ID: 116487
Article Last Modified on 7/5/2005
/* Compile options needed: none
*/
#include <iostream.h>
class B;
class A
{
public:
// This is the function the compiler
// chooses to call.
A(B&) { cout << "called A::A(B&)" << endl; }
};
class B
{
public:
operator A() // This function does not get called.
{
B b;
cout << "called operator B::A()" << endl;
return b;
}
};
void main()
{
B b;
A a = b; // A(b) or b.operator A()?
// The compiler should issue an
// error here but instead chooses
// to call A::A(B&).
cout << "failed: should not compile- see ARM 12.3.2" << endl;
}
Additional query words: kbVC400bug 8.00 8.00c 9.00
Keywords: kbbug kbcpponly kbcompiler KB116487