Re: [Dev-C++] How would you write a method returning a string ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: matheus r. <mfr...@gm...> - 2007-07-23 00:41:32
|
> I have many classes that manipulate the string and then returns it either as > a 'const char*', 'std::string', 'int', and so on and so forth, the method is > just part of the class, so instead of writing a stand alone function, it is > better to pack it up within the class, after all... that is the nature of > Object Oriented Programming. As long as the reference you return exists, no problem. But suppose the object of the class mentioned is destroyed, your string reference will be dangling, yielding undefined results. Of course, as long as you know what youre doing, youre fine. But I wouldnt advice people, specially novices, doing that sort of function. Just MHO. |