What is static function? Explain with an example



What is static function? Explain with an example..

Answer / Satish Kumar Agrahari

A static function is a member function that does not operate on any specific object of the class and does not have access to non-static members or the this pointer. Static functions can be called without creating an object of the class.nExample:n```cppnclass MyClass {npublic:n static void showMessage() {n std::cout << "Hello, World!
";n }n};nMyClass::showMessage(); // Output: Hello, World!

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

How the V-Table mechanism works?

6 Answers   HP,


What are move semantics?

1 Answers  


List the advantages of inheritance.

1 Answers  


Can malloc be used in c++?

1 Answers  


Explain the benefits of proper inheritance.

1 Answers  


What is data binding in c++?

1 Answers  


What are maps in c++?

1 Answers  


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

1 Answers  


Which operator cannot overload?

1 Answers  


What are static variables?

1 Answers  


How do c++ struct differs from the c++ class?

1 Answers  


Why is it difficult to store linked list in an array?

6 Answers   Infosys, Lucent,


Categories