Open In App

C++ | Virtual Functions | Question 11

Like Article
Like
Save
Share
Report

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




#include<iostream> 
using namespace std;    
 
class Test
{
   public:
      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


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads