I
iu2
Hi all,
I find myselft wondering about the recommended way to pass strings to
functions:
int func(string s);
or
int func(const char *s);
I usually pass a const char * since it's shorter referring to s
instead of s.c_str() inside 'func'. In case some string manipulation
need arises, I can always launch a string or a stringstrem insinde
'func'.
Is there a good reason to pass a 'string' instead of a const char * ?
thanks
iu2
I find myselft wondering about the recommended way to pass strings to
functions:
int func(string s);
or
int func(const char *s);
I usually pass a const char * since it's shorter referring to s
instead of s.c_str() inside 'func'. In case some string manipulation
need arises, I can always launch a string or a stringstrem insinde
'func'.
Is there a good reason to pass a 'string' instead of a const char * ?
thanks
iu2