Re: Ambiguous conversions
Re: Ambiguous conversions
- Subject: Re: Ambiguous conversions
- From: Adin Hunter Baber <email@hidden>
- Date: Fri, 23 Jun 2006 13:30:06 -0500
On 2006 Jun 23, at 12:33 PM, Mark Wagner wrote:
It's not the constant that's the problem. Here's a code sample that
demonstrates what's going on:
class MString
{
public:
MString( const char* str , long length );
operator const char*( void ) const;
operator const wchar_t* (void ) const;
operator const unsigned char*( void ) const;
const wchar_t& operator[]( long index ) const;
};
int main(void)
{
MString str("test", 5);
return str[2]; // <-- Error occurs here
}
Is there any way to fix this, preferably without removing the
typecasts from the class, and without changing the 1,800 lines of code
where the error is occuring? Say, with a minor tweak to the class, or
by telling the compiler to go back to its old behavior?
I ran into this problem recently. The only way I found to solve it
was by making the parameter for operator [] an int.
Adin Hunter Baber
email@hidden
"Theory and practice are the same in theory, but different in practice."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden