Interview Questions   Tutorials   Discussions   Programs   Videos   

C++ - What is the use of static functions?

asked marvit August 19, 2014 08:15 AM  

What is the use of static functions?


1 Answers

answered By bhjahnavi   0  
By declaring a function member as static, you make it independent of any particular object of the class. A static member function can be called even if no objects of the class exist and the static functions are accessed using only the class name and the scope resolution operator ::.
A static member function can only access static data member, other static member functions and any other functions from outside the class.
Static member functions have a class scope and they do not have access to the this pointer of the class. You could use a static member function to determine whether some objects of the class have been created or not.
   add comment

Your answer

Join with account you already have



Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!