Skip to content
Related Articles

Related Articles

Improve Article

C++ | Virtual Functions | Question 11

  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021
Geek Week

Can static functions be virtual? Will the following program compile?

using namespace std;    
class Test
      virtual static void fun()  { }

(A) Yes
(B) No

Answer: (B)

Explanation: Static functions are class specific and may not be called on objects. Virtual functions are called according to the pointed or referred object.

Quiz of this Question

Take a step-up from those “Hello World” programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :