|
-
May 6th, 2010, 09:30 AM
#1
[RESOLVED] is const char* to string conversion safe?
we have a function f with gets a string as below
Code:
void f( std::string str )
{
// body
}
is it safe to call this function with a const char* varialbe like below
Code:
void g( const char* phrase )
{
f(phrase);
}
-
May 6th, 2010, 09:32 AM
#2
Re: is const char* to string conversion safe?
-
May 6th, 2010, 10:42 AM
#3
Re: [RESOLVED] is const char* to string conversion safe?
The argument is non-reference, non-pointer std::string, the object of type string will always be created even if you pass string object. Appropriate constructor would be called for initializing the function argument.
When function returns, the destructor will be called.
Thus, is it absolutely safe.
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
|