// GetWelcomeMessage can only be accessed in the current .CPP file std::cout << GetWelcomeMessage();// It will display Welcome to my static function as output

}

Can I have a static function in a class? Of course, YES. You can have any number of static function. If it is a public static function, you do not even need any class object to access the static member function. You can access it by <class name>::<static function name>.

A typical example for static function is singleton class. static MySingletonClass* GetInstance() is a static member function in the class and it is used in the main function.