What is the use of static member functions in class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the use of static member functions in class?

i know how static data members work but i couldn't figure out how static member functions come in handy someone pls give a possible purpose for it thanks in advance

5th Jan 2017, 2:30 PM
SANJAY SIDDHARTH C V
SANJAY SIDDHARTH C V - avatar
1 Answer
+ 1
Static members, just as static classes, dont belong to any objects. So they are something like stand-alone members or classes which can be called anytime anywhere (as long as they are declared as global members or global classes i guess). So performing some operations on different variables or class members of the same datatype requires unique methods, which don't belong to any objects. That's where static members come in handy.
5th Jan 2017, 3:07 PM
Alireza Bahram
Alireza Bahram - avatar