Which of the following can not be declared as virtual

A) Static functions
B) Member fields
C) Instance functions

Showing Answers 1 - 4 of 4 Answers

samiksc

  • Jan 9th, 2006
 

Both A and B are correct choices. Declaring a static function as virtual generates build error. Same with declaring member fields as virtual.

A static function can be called only using class_name.static_function_name() syntax, so there is no run-time resolve depending on the type of object, hence the term virtual does not make a sense in case of static functions.

In case member fields are overriden by a derived class the derived class methods will use the overriden variables by default, so there is no run-time resolve required for fields.

EM

  • Feb 27th, 2006
 

>>Same with declaring member fields as virtual.Author, if you are a full lamer dont write anything !!!

  Was this answer useful?  Yes

Tommie

  • Mar 29th, 2006
 

(A) - "A static member ..... cannot be marked as override, virtual, or abstract

(B) - "The modifier 'virtual' is not valid for this item

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions