compile error when using copy operator
Any idea why I should be getting this error?
I create 2 objects of the same class and then try to set one equal to the other. The class does have a overloaded copy operator? TString temp1; TString temp2; temp1 = temp2; error: no matching function for call to ‘TString::TString(TString)’ note: candidates are: TString::TString(TString&) note: TString::TString(const char*) const TString &TString::operator = (const TString &Src) { return Copy(Src); } arm-angstrom-linux-gnueabi-g++ (GCC) 4.2.4 Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
Quote:
|
Yes it does have a default constructor taking no arguments:
TString::TString() : TObj("String") { Len = 0; MaxLen = 0; Copy(""); } |
(Sorry wrong topic)
|
Something I have found is if I use the following compiler version I do no get the error. But now there are issues regarding shared libriaris (libc) on my target system which is using applications compiled with the orginal cross compiler version. Any suggestions if I should change the code to work with the old compiler or use the new compiler for the specific application and add the new libraries which I am not sure how to do this without causing compatibility issues on the target. Any help is appreciated.
arm-linux-gnueabi-g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
Quote:
|
pleas use code tags
this Code:
const TString &TString:perator = (const TString &Src) it is possible that this Code:
TString temp1; what optimization level did did you pass to the compiler? please provide complete information in your question. however, if you think you need an assimgent operator you need also others read this http://en.wikipedia.org/wiki/Rule_of...programming%29 general, you do not implement your own string class, or if you do just for learning? |
All times are GMT -5. The time now is 11:26 PM. |