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 setf in c++?

579


What is constructor c++?

668


What is a sequence in c++?

582


What are the uses of c++ in the real world?

562


How do you declare a set in c++?

536






Why c++ is faster than java?

596


How can I learn dev c++ programming?

567


Can we specify variable field width in a scanf() format string? If possible how?

662


What is insertion sorting?

668


How do you master coding?

562


Explain overriding.

604


Why main function is special in c++?

667


Why do we use constructor?

601


What is malloc in c++?

557


What is scope resolution operator in c++ with example?

557