Confused on Addresses and Constructors

I understand the basics of the two pretty well. But I was given code to work on and am completely confused on how to work with it. This is what I'm given:

Roman(const string&);

There's a comment on it that says it accepts a string and converts it internally to an integer. I'm obviously supposed to do the conversion in the {} after, but I'm confused out of my mind what I'm even passing in as a string. Why is there an & after the string? I probably have to declare a string variable in the private of the class, but how would I put that in with the &?
Last edited on
Why is there an & after the string?

It's a reference, conceptually like passing a value with a pointer. An object like a string or any other class or container can be potentially large, so we pass it by reference. I say conceptually because, in the STL it's all mixed in with Template Meta Programming (TMP). It can also be thought of as being another name for an object. These analogies work well, a reference behaves like a pointer.

There is a difference between a C++ reference, and passing a raw pointer (Like one would do with C). A reference must refer to an object, whereas a pointer can point to anything, including nothing (nullptr).

Google this, there is much more than what I have briefly mentioned here.
Topic archived. No new replies allowed.