Hello, I looked some in the archives for a report of something like this, but didn't see anything. Apologies if I missed it. I'm having a problem getting Cint to handle a construction in an interpreted script. I have a compiled class with both a constructor and an operator+ defined for const char *: class A { public: A(): mString() {} A(const A &s): mString(s.mString) {} A(const char *s): mString(s) {} virtual ~A() {} A operator +(const char *s) { A r = mString.c_str(); r.mString += s; return r; } const char *val() const { return mString.c_str(); } private: std::string mString; ClassDef(A, 1) }; The usage I'd like to work is: A a = A("A part") + " of a whole"; That is, I'd like to create a temporary A from one string, and then concatenate another string to that, and then use the resulting temporary object to initialize my l-value A object, a. This works fine if I compile the script, but in the interpreter I get the following error: Error: Can't call A::A("A part")+" of a whole" in current scope FILE:A_test.C LINE:25 Possible candidates are... filename line:size busy function type and name (in A) (compiled) 0:0 0 public: A A(void); (compiled) 0:0 0 public: A A(const A& s); (compiled) 0:0 0 public: A A(const char* s); *** Interpreter error recovered *** Thus, Cint seems to think the whole rhs of the assignment is included in the constructor call. Experimentally, I find that Cint does the right thing if I add parentheses around the explicit temporary object, i.e.: A a = (A("A part")) + " of a whole"; Attached is a tar file, with a README describing how to reproduce the problem. Thanks, James PS: I see this problem on both SunOS 5.8, with the WS 6.0 compiler, and RedHat Linux 7.1, with g++ 3.1.1. In both cases, the Root version is 3.03.07, which comes with Cint 5.15.50.
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET