C Programming What are the differences in the function calls

C++ Programming

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;

Solution

1)void Shape :: member ( Shape s1, Shape s2 ) ; // pass by value, argument type is pass by value. you can pass values to function. 2)void Shape :: member ( Shape *s1, Shape *s2 ) ; // pass by pointer, you can pass pointer as a argument. 3)void Shape :: member ( Shape& s1, Shape& s2 ) const ; // pass by reference, you can pass the refrence or address of data. 4)void Shape :: member ( const Shape& s1, const Shape& s2 ) ; // pass by const reference 5)void Shape :: member ( const Shape& s1, const Shape& s2 ) const ; // plus the function is const
C++ Programming 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site