I have a class with an overloaded [] operator, as follows:
The class also has a char*() operator, as follows:Code:char & STRING::operator[] (unsigned); char STRING::operator[] (unsigned) const;
The problem is, when I try a some code such as:Code:STRING::operator char* ();
I get a compiler error saying that this operator[] call is ambiguous, that it can't decide between my STRING:Code:STRING a; a[0] = 'A';perator[] and the built-in operator[] that works for char pointers. So far the only thing I can think of is that the compiler is implicitly casting my STRING to a char * using my operator char*() function. The only way this code works is if I comment out the prototype for operator char*. Unfortunately, I need to have that function working. Any help out there for me?



LinkBack URL
About LinkBacks
perator[] and the built-in operator[] that works for char pointers. So far the only thing I can think of is that the compiler is implicitly casting my STRING to a char * using my operator char*() function. The only way this code works is if I comment out the prototype for operator char*. Unfortunately, I need to have that function working. Any help out there for me? 



CornedBee