prototype for toString() method
From: qazmlp (qazmlp1209_at_rediffmail.com)
Date: 01/31/04
- Next message: Peter Koch Larsen: "Re: prototype for toString() method"
- Previous message: Christopher Benson-Manica: "Re: The Best C++ Compiler"
- Next in thread: Peter Koch Larsen: "Re: prototype for toString() method"
- Reply: Peter Koch Larsen: "Re: prototype for toString() method"
- Reply: Rolf Magnus: "Re: prototype for toString() method"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Jan 2004 00:16:51 -0800
I have a class containing 5-6 member data. I want to provide a toString() method
as a part of this class to help the users to do tracing.
const std::string& toString()
{
std::string objectData ;
objectData = "memberData1=" + memberData1 ;
objectData += " memberData2=" + memberData2 ;
objectData += " memberData3=" + memberData3 ;
objectData += " memberData4=" + memberData4 ;
objectData += " memberData5=" + memberData5 ;
return objectData ;
}
Is the function signature Ok? Or, do you suggest to make it as
"std::string toString()" ? If yes, why?
Do you suggest any improvements in the above code?
- Next message: Peter Koch Larsen: "Re: prototype for toString() method"
- Previous message: Christopher Benson-Manica: "Re: The Best C++ Compiler"
- Next in thread: Peter Koch Larsen: "Re: prototype for toString() method"
- Reply: Peter Koch Larsen: "Re: prototype for toString() method"
- Reply: Rolf Magnus: "Re: prototype for toString() method"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]