Today I got a problem. I am in the need of a static member function, const is not a must but a better. But, I didn’t succeed in my efforts. Can anybody say why or how?
Today I got a problem. I am in the need of a static member
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you apply the
constqualifier to a nonstatic member function, it affects thethispointer. For a const-qualified member function of classC, thethispointer is of typeC const*, whereas for a member function that is not const-qualified, thethispointer is of typeC*.A static member function does not have a
thispointer (such a function is not called on a particular instance of a class), so const qualification of a static member function doesn’t make any sense.