Vip
Answered On : May 1st, 2012
Derived class display with i = 10

3 Users have rated as useful.
Login to rate this answer.
Shobhit Chaturvedi
Answered On : May 12th, 2012
dervie class function display
Login to rate this answer.
Derived class display with i = 20

1 User has rated as useful.
Login to rate this answer.
Derived class display with i = 10
Login to rate this answer.
saum almas
Answered On : May 30th, 2012
Derived class display with i = 10
Login to rate this answer.
Deepak
Answered On : Jun 13th, 2012
Derived class display with i=10 because in virtual functions do pass the default arguments if you are passing then made both versions of function with same default argument
Login to rate this answer.
Mahesh
Answered On : Jun 20th, 2012
Derived class display method with i=20, because assigning derived object to base class reference. so derived class display method will call
Login to rate this answer.
Teodor
Answered On : Aug 6th, 2012
It indeed displays "Derived class i=10". What happens is that through polymorphism, the base * obj = new derived() object can have access to the body of the overridden method, but its signature containing the default value for the "i" parameter is taken from the base class. That's because of the run-time vtable mechanism: the function is called for a base object, but the vtable fetches the implementation for the overridden one, from the derived class. Hence the odd output.
Login to rate this answer.
abhimanyu
Answered On : Aug 9th, 2012
it will be 20
Login to rate this answer.
Answer is : "derived class display with i=10"
Login to rate this answer.
reddy-
Answered On : Apr 10th, 2013
Overriding function default argument takes more precedence ,Hence based class default argument 10 will be initialized to i.So i value holds 10 will be printed for this call with derived count statement.
Login to rate this answer.