1 What are the differences in the function calls between the

1.) What are the differences in the function calls between the four member functions of the Shape class below?

void Shape::member(Shape s1, Shape s2);

void Shape::member(Shape *s1, Shape *s2);

void Shape::member(Shape& s1, Shape& s2) const;

void Shape::member(const Shape& s1, const Shape& s2);

void Shape::member(const Shape& s1, const Shape& s2) const;

also,

Given the following definition of Value::operator=

1) Value& operator=(const Value &rhs)

2) {

3) if (&rhs == this)

4) return *this;

5) v = rhs.v;

6) return *this;

7) } Explain the meaning of \'&\' on line 1 and on line 3 separately.

Many thanks!

Solution

1)

void Shape::member(Shape s1, Shape s2); ---- This is pass by value

void Shape::member(Shape *s1, Shape *s2); ---- This is pass by pointer

void Shape::member(Shape& s1, Shape& s2) const; ---This is pass by reference

void Shape::member(const Shape& s1, const Shape& s2); --- This is pass by constant reference

void Shape::member(const Shape& s1, const Shape& s2) const; ---This is pass by constant reference but also the function is constant too

2)

1.) What are the differences in the function calls between the four member functions of the Shape class below? void Shape::member(Shape s1, Shape s2); void Shap

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site