What is the use of static functions?

Answer Posted / v venkatesh

The differences between a static member function and non-
static member functions are as follows.

A static member function can access only static member
data, static member functions and data and functions
outside the class. A non-static member function can access
all of the above including the static data member.

A static member function can be called, even when a class
is not instantiated, a non-static member function can be
called only after instantiating the class as an object.

A static member function cannot be declared virtual,
whereas a non-static member functions can be declared as
virtual

A static member function cannot have access to the 'this'
pointer of the class.
The static member functions are not used very frequently in
programs. But nevertheless, they become useful whenever we
need to have functions which are accessible even when the
class is not instantiated.

Is This Answer Correct ?    70 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between an external iterator and an internal iterator?

829


What do you mean by function and operator overloading in c++?

783


What is virtual methods?

860


What is the difference between a template and a macro?

779


What is class definition in c++ ?

806






Why do we use templates?

784


Is c or c++ more useful?

781


Write a program to find the reverse Fibonacci series starting from N.

796


What is the best book for c++ beginners?

753


Define vptr.

753


What do you mean by volatile and mutable keywords used in c++?

748


How a modifier is similar to mutator?

848


How do I make turbo c++ full screen?

773


What is a forward referencing and when should it be used?

807


Is it possible to pass an object of the same class in place of object reference to the copy constructor?

761