This is a interview question. So is it possible to override a method without virtual specified in parent method?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They probably wanted you to say “Use the
newkeyword to hide the method.” Which technically does not override the method. If you haveAnd then you wrote
You would see different results. So functions that use the base class would get the results for the base method, and functions that use the derived class would get the results for the new method.