If we create a member function of a class as static it is called a Static member function in c++.
Static Member function used only static data members.
It is also accessible if we do not have any object of a class. we can access static member functions using class name and scope resolution operator (: : ).
Static member function it is not part of any object, it is called using the classname.

Syntax of static member function in c++ :
class class_name{ static function_name(); } class_name : : function_name();
class_name: class name is the name of a class.
function_name: function name is the name of a static function.
Also Read This :- static data members in c++
Example :
#include<iostream> #include<conio.h> using namespace std; class item { Â Â Â Â Â Â Â static int count; Â int code; Â public: Â void setcode(void) Â { Â Â code = ++count; Â } Â void showcode(void) Â { Â Â cout<<"object number is = "<<code<<"n"; Â } Â static void showcount (void) Â { Â Â cout<<"count is = "<< count<<"n"; Â } }; Â int item :: count=8; main(){ Â item obj1,obj2; Â obj1.setcode(); Â obj2.setcode(); Â item :: showcount(); Â item obj3; Â obj3.setcode(); Â item :: showcount(); Â obj1.showcode(); Â obj2.showcode(); Â obj3.showcode(); Â getch(); Â return(0); }
output :
count is = 10 count is = 11 object number is = 9 object number is = 10 object number is = 11