R
Rick Helmus
Hello all
In a few classes I have overloaded functions for C style strings and
STL strings like this
class SomeClass
{
void f(const char *s);
void f(const std::string &s);
};
At some point I forgot to include a C string function version in a
class, but noticed it all worked fine with const char *'s anyway...
In other words; const std::string &str = "blah"; works (a non const
reference won't). AFAIK this means it's a reference directly to a const
char *, can someone explain me why this would work?
Cheers, Rick
In a few classes I have overloaded functions for C style strings and
STL strings like this
class SomeClass
{
void f(const char *s);
void f(const std::string &s);
};
At some point I forgot to include a C string function version in a
class, but noticed it all worked fine with const char *'s anyway...
In other words; const std::string &str = "blah"; works (a non const
reference won't). AFAIK this means it's a reference directly to a const
char *, can someone explain me why this would work?
Cheers, Rick