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

Explain unexpected() function?

586


What is the difference between global variables and local variable

538


Is dev c++ a good compiler?

526


Write my own zero-argument manipulator that should work same as hex?

589


Why should we use null or zero in a program?

606






What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

564


What are c++ templates used for?

621


What is a map in c++?

584


Is linux written in c or c++?

557


Write a program which uses functions like strcmp(), strcpy()? etc

623


Is c++ used anymore?

595


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

1587


which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?

722


You run a shell on unix system. How would you tell which shell are you running?

663


Are strings mutable in c++?

694