Hi,
If I have a method that has string reference as a parameter, what
happens if I pass a const char* variable to this method?
One thought is that a temporary string will be created in the stack
and the parameter will refer to this object. Is this correct?
Does this mean if a constructor of a class has a string reference
parameter, the temporary string that is created in the stack is
destroyed after the contruction of the object is complete?
** Example**
e.g:
class x {
public:
x(std::string& name);
};
void main()
{
const char* const text = "Name";
x newObject(name);
}
Can anyone help me understand what happens during and after the
newObject is created?
Thanks,
-PJ.