J
johan.ekman
I found a function in our code with a similar principle as:
const char* MyString() const
{
return "Hello!";
}
I believe this function is wrong because "Hello" string would be
allocated locally on the stack ?!? (right) and therefore the method
would return a pointer to an object that not exists outside this
method.
Doesn't that mean that a call such as:
sprintf( MyString() );
might output nonsense ?
Thanks / Cooper
const char* MyString() const
{
return "Hello!";
}
I believe this function is wrong because "Hello" string would be
allocated locally on the stack ?!? (right) and therefore the method
would return a pointer to an object that not exists outside this
method.
Doesn't that mean that a call such as:
sprintf( MyString() );
might output nonsense ?
Thanks / Cooper