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

Show the application of a dynamic array with the help of an example.

885


What is constructor c++?

890


Explain what data encapsulation is in c++?

808


What is binary search in c++?

809


Explain linked list using c++ with an example?

830


Keyword mean in declaration?

824


Which c++ operator cannot overload?

760


Define Virtual function in C++.

862


Is c++ vector a linked list?

791


What are friend functions in C++?

838


What is else if syntax?

905


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

804


What is iterator c++?

737


What is a stack? How it can be implemented?

934


find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.

2243