cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
What are the differences
What are the differences
Dec 20, 2008 at 11:58am UTC
cired
(4)
guys i have two items below and i just want to know the differences between them.
1. myfunction(std::string("first word") + " " + "second word");
2. myfunction("first word" + " " + "second word");
void myfunction(std::string buff)
{
...
}
Thanks in advanced,
Dec 20, 2008 at 12:49pm UTC
Bazzy
(6281)
1: the pointer
"first word"
is converted to an
std::string
, so the + is
std::string
operator
+ (
const
string&,
const
char
*)
2: the pointer is not converted so it could generate errors unless the compiler converts it implicitly
Dec 20, 2008 at 1:01pm UTC
cired
(4)
thanks man for the your reply.
Dec 20, 2008 at 5:19pm UTC
helios
(17574)
unless the compiler converts it implicitly
Which will never happen.
Topic archived. No new replies allowed.