passing reference into constructor

If I have a class named "whatever" with a string member str, and it has the following constructor:

whatever(std::string & s) : str(s) {}

Does s get copied into str or do both s and str end up refering to the same string?
Last edited on
It depends on how you declared str. Is it a reference or not?
If it is a reference, then by definition they refer to the same string.
If it is not, then there are two separate string instances that can be
changed without affecting the other.

Ok, thanks.
Topic archived. No new replies allowed.