What is the use of static functions?

Answer Posted / reejusri

Static function is basically used in creating factory
objects.
You can make your constructor private and expose static
function. And user can use the static methods to create the
object of that class.
Using NONSHARABLE_CLASS you can restrict the usage of
static functions/method also.

Is This Answer Correct ?    15 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you decide which integer type to use?

579


Explain bubble sorting.

628


Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

616


How does code-bloating occur in c++?

753


Why isn't sizeof for a struct equal to the sum of sizeof of each member?

544






Difference between a copy constructor and an assignment operator.

578


Is it possible to use a new for the reallocation of pointers ?

601


What is a v-table?

647


What is the difference between a baller and a reference in C++?

578


What is iostream in c++ used for?

551


Describe delete operator?

625


Explain what happens when a pointer is deleted twice?

733


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

583


What is the use of turbo c++?

551


Can you declare an array without a size in c++?

574