0

What does this expression mean float pay(float hoursWorked) const;

In C, if we return a const one, const float f ()... what does this mean by putting const in the last

user3341953
  • 309
  • 1
  • 5
  • 14

1 Answers1

1

It is a declaration of non-static member function of some class

float pay(float hoursWorked) const;

The last qualifier const means that the object for which this function is called is considered as a constant object and this function may no change its data members except those that were declared with specifier mutable.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
  • thanks, I also search static function member. what does static mean. It seems that static function could not change the private member? – user3341953 Mar 10 '14 at 03:07
  • @user3341953 No it is a wrong statement. static member functions as non-static member functions can change private data members of a class where they are defined. Static member functions are called without an instantiation of an object. They are "class-wide" functions while non-static member functions are "object-wide" functions. – Vlad from Moscow Mar 10 '14 at 03:11