What is a static function ?
A static function inside a class gives us the ability to call the function a class without initializing the class
For example:- in the below example animal is class and lion() is a static function inside it.
class Animal { public static function lion(){ } }
Now, as lion() is a static function it can be accessed without initialization of the class i.e. without making an object of the class.
thus to acess a static function write
animal::lion();
Share