euamts@eua.ericsson.se (Mats Henricson) (12/14/90)
Gee... I have had this weird bug on my screen for two days now and I'm getting mad. The thing is, I'm implementing a string-class in much the same way as NIH and the gnu-library. This means having a substring-class doing some dirty work for the ordinary string-class. The problem is when I try to overload the + operator for reversed left and right valuses, i.e.: friend String operator+(const char*, const SubString&); When I try to use it in statements like: String a = "I like C++"; String b; b = "I don't " + a(2,8); //error I get the terrific report saying: error: initializer for non-const reference not an lvalue The function has to be friend to both String and SubString, but I don't think the problem is because of anything related to the friendness to both these functions. The problem is no doubt related to the friendness, since other similar friend-functions gives the same error. If I do the reversed thing with the member-operator+ : b = a(7,3) + " can make you sick"; Is there anyone out there that might know what all this is about, or do you need more information? Mats Henriksson / mats.henriksson@eua.ericsson.se