Suppose we have a class called Line
that contains the following modifier that assigns a value to a class data member.
void Start(const Point &start);
The line class contains two data members called start and end which are both Point objects. Since the start
variable in the function parameter is a reference, and I implement it as follows:
void Line::Start(const Point &start) {
m_start = start;
}
In the main function I have the following.
Line line;
Point start(1, 1);
line.Start(start);
Would the m_start
data member now refer directly to the start
Point
object in the main function since it was passed by reference?