41.0k views
5 votes
If a member function promises not to change the object to which it is applied, that function should be marked as:______

a. abstract
b. const
c. friend
d. static
e. none of the above

User Tene
by
5.8k points

1 Answer

5 votes

Answer:

The correct answer is b)const

Step-by-step explanation:

a. abstract : Abstract function does not guarantees to not change the object to which it is applied

b. const : A const member function is a member function that guarantees it will not modify the object and it can not call any non-const member functions that may change the object. So no chance to change object through const functions.

c. friend : Friend function is a function that is given the same access as methods to private and protected data and it can change the object.

d. static : Static function can be called without object reference but they can also be called called through object reference using "this" pointer keyword which may modify object data.

e. none of the above: Const function can not change the object so none of above is incorrect option.

User Laxmi
by
5.3k points