-
October 23rd, 2003, 07:00 PM
#16
So, now that I have the function Paul, what is the best way to use it? Start a GeneralFoo.h /GeneralFoo.cpp file and include into projects where I want to use it? Generate a GeneralFoo.dll? Create a CGeneralFoo class?
Thanks for the starter code BTW.
Mike B
-
October 24th, 2003, 03:25 AM
#17
Originally posted by Paul McKenzie
It does...
std::ostringstream::str() returns a std::string.
I was referring to the uncorrected version which used As Mike said, it compiled, but crashed.
-
October 24th, 2003, 03:30 AM
#18
Originally posted by MikeB
So, now that I have the function Paul, what is the best way to use it? Start a GeneralFoo.h /GeneralFoo.cpp file and include into projects where I want to use it?
This is OK.
Generate a GeneralFoo.dll?
I wouldn't do this -- it is much simpler just to include the code in whatever module you want to use it in.
Create a CGeneralFoo class?
I would just stick to it being a standalone function.
Regards,
Paul McKenzie
-
October 24th, 2003, 03:53 AM
#19
Originally posted by gstercken
I was referring to the uncorrected version which used As Mike said, it compiled, but crashed.
It should never have compiled, regardless of whether the return type was std::string or not.
From the Comeau compiler:
Code:
#include <sstream>
#include <string>
std::string foo()
{
std::ostringstream strm;
return strm.str;
}
using namespace std;
int main()
{
std::string s = foo();
}
Compiler output:
"ComeauTest.c", line 7: error: a pointer to a bound function may only be used to
call the function
return strm.str;
^
1 error detected in the compilation of "ComeauTest.c".
Regards,
Paul McKenzie
-
October 24th, 2003, 04:03 AM
#20
Originally posted by Paul McKenzie
It should never have compiled, regardless of whether the return type was std::string or not.
Yea, you're right. A pointer to a nonstatic member function can't be returned. So this is yet another bug in the MS compiler.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|