Which of the following is NOT correct about virtual functions in C++? I. A…

2021

Which of the following is NOT correct about virtual functions in C++?

I. A virtual function must be a member of a class.

II. It can be accessed using an object pointer or reference.

  1. A.

    Only I

  2. B.

    Only II

  3. C.

    Both I and II

  4. D.

    Neither I nor II

Attempted by 151 students.

Show answer & explanation

Correct answer: D

Key idea

A virtual function in C++ is a member function declared with the virtual keyword, usually in a base class.

Statement check

  • Statement I: Correct. A non-member or global function cannot be declared virtual.

  • Statement II: Correct. Dynamic binding is commonly achieved by calling the virtual function through a base-class pointer or reference.

Conclusion

Both statements are correct, so no listed statement is “NOT correct.”

Final answer: Neither I nor II.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs