Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!asuvax!noao!arizona!sunquest!francis From: francis@sunquest.UUCP (Francis Sullivan) Newsgroups: comp.lang.c++ Subject: warning message from Sun C++ 2.0 Message-ID: <1286@sunquest.UUCP> Date: 19 Dec 89 17:34:57 GMT Organization: Sunquest Information Systems, Tucson Lines: 35 I have just started learning C++, and was experimenting with a string class for practice. Using g++ 1.34.2, I don't get warning messages with the following program, but I do with Sun C++ 2.0. ############# file nstr.cc ############ class Str { public: Str(Str&); Str(char *); Str(); ~Str(); Str& operator= (Str& s1); Str friend operator+ (Str& s1, Str& s2); }; main (int argc, char *argv[]) { Str c; for (int i = 1; i < argc; i++) c = Str(argv[i]) + " " + c; } // eof of nstr.cc now using Sun C++ 2.0 CC -g -c nstr.cc CC +g nstr.cc: "nstr.cc", line 13: warning: temporary used for non-const Str & argument "nstr.cc", line 13: warning: temporary used for non-const Str & argument ########## The program works fine, but I want to be able to do operations like above without getting the warning message. Any solutions besides delaring temporary strings for " " and the strings built from argv? -- Francis Sullivan Senior Programmer/Analyst Sunquest Information Systems Tucson, AZ email: francis@sunquest.com or sunquest!francis@arizona.edu or {uunet,arizona}!sunquest!francis