Should a member function that returns a static member variable also be static?
For instance:
struct T {
static int i;
static int getNumber() {
return i;
}
};
Should getNumber be static or not?
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.
Usually, yes.
If the variable doesn’t have any per-instance state, then what possible per-instance logic could the function perform on it before returning it?