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

Can you pass a vector to a function?

532


Why do we need constructors in c++?

604


What are the rules about using an underscore in a c++ identifier?

626


what is a reference variable in C++?

649


Can we overload operator in c++?

544






Define upcasting.

585


How many namespaces are there in c++?

551


Write about the stack unwinding?

620


What are abstract data types in c++?

524


Why main function is special in c++?

654


What happens if a pointer is deleted twice?

781


What is c++ best used for?

556


What is different in C++, compare with unix?

597


In c++, what is the difference between method overloading and method overriding?

585


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

567