I have an assignment that is basically "implement your own c-string class". The overloaded assignment operator is declared as: ourString & ourString::operator=(const ourString & orig);
With that function one object copies to another fine, but I need to be able to pass it a string literal. If I create ourString & ourString::operator=(string orig)
the compiler complains that calling it with a string literal is ambiguous.
If I comment out the string version it will compile but then there are runtime errors. What am I missing?
there may be some bug in your ourString constructors. ( what is the runtime error about ? )
If you want to be sure to have an operator= which takes a string literal, overload it as constchar*
Some kind of heap corruption error. I thought it was happening because when a string was assigned to an object its other members (capacity, length) were getting set to garbage values, but I just noticed I was trying to send a char to an array index in one of the tests...
Is something like this what you're talking about? Now Intellisense says, "no instance of overloaded function 'ourString::operator=' matches specified type".