Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!ericom!eua.ericsson.se!euamts From: euamts@eua.ericsson.se (Mats Henricson) Newsgroups: comp.lang.c++ Subject: error: initializer for non-const reference not an lvalue ?? Keywords: bugs bug c++ friends Message-ID: <1990Dec14.132210.29615@eua.ericsson.se> Date: 14 Dec 90 13:22:10 GMT Sender: news@eua.ericsson.se Distribution: comp Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden Lines: 32 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