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 function prototyping? What are its advantages?

818


what is Member Functions in Classes?

829


Explain shallow copy?

799


What is const pointer and const reference?

832


What is stream and its types in c++?

776


Explain deep copy?

805


Difference between class and structure.

895


How can a struct in c++ differs from a struct in c?

807


How many types of classes are there in c++?

798


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

843


What is anonymous object in c++?

846


Explain operator overloading.

817


How come you find out if a linked-list is a cycle or not?

783


What is #include iostream?

980


Describe linked list using C++ with an example.

858