Output of following C++ program?
Contributed by Pravasi Meet
(A) fun() is static
(B) Empty Screen
(C) Compiler Error
Explanation: The above program fails in compilation and shows below error messages.
[Error] cannot declare member function ‘void Test::fun()’ to have static linkage [-fpermissive]
In function ‘int main()’:
[Error] cannot call member function ‘void Test::fun()’ without object
If the static function is to be defined outside the class then static keyword must be present in function declaration only not in the definition outside the class.
Following program is now correct.