[Bug c++/32944] New: operator= not ambiguous overload but does not compile

2007-07-31 Thread Dallas at ekkySoftware dot com
#include 
#include 

class CString{
public:
CString(){value = NULL;}
CString(char *initValue){
if(initValue != NULL) value = NULL; 
else strcpy((value = new char[strlen(initValue)+1]),initValue);
}
~CString(){if(value != NULL) delete [] value;}
CString& operator=(char* newValue){
if(value != NULL) delete [] value;
if(newValue != NULL) value = NULL; 
else strcpy((value = new char[strlen(newValue)+1]),newValue);
}
CString& operator=(CString& newValue){
if(value != NULL) delete [] value;
if(newValue.value != NULL) value = NULL; 
else strcpy((value = new
char[strlen(newValue.value)+1]),newValue.value);
}
CString operator+(char *addValue){
CString tempValue;
strcpy((tempValue.value = new char[strlen(value) +
strlen(addValue) + 1]),value);
strcat(tempValue.value,addValue);
return CString(tempValue.value);
}
CString operator+(CString& addValue){
CString tempValue;
strcpy((tempValue.value = new char[strlen(value) +
strlen(addValue.value) + 1]),value);
strcat(tempValue.value,addValue.value);
return CString(tempValue.value);
}
char *value;
};

int main(int argc, char *argv[])
{
CString a("First String"), b("Second String"), c;
c = a + " - " + b;
printf(c.value);
}


-- 
   Summary: operator= not ambiguous overload but does not compile
   Product: gcc
   Version: 4.0.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: Dallas at ekkySoftware dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32944



[Bug c++/32944] operator= not ambiguous overload but does not compile

2007-07-31 Thread Dallas at ekkySoftware dot com


--- Comment #2 from Dallas at ekkySoftware dot com  2007-08-01 00:14 ---
The reason I was passing the reference and not the value is because is some
circumstances I can change the value of the parameter. Using the const keyword
prevents me from calling methods that can change the value – even if in this
example they do not.

Thanks,
Dallas Clarke

BSc (CS) LLB UNSW
Architect / Lead Developer 
Ekky Software


Website: http://www.ekkySoftware.com 


-- 

Dallas at ekkySoftware dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32944