NetApp Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

Sole purpose of having virtual functions is code maintenance and nothing else.
Suppose you wrote a code which is based on calling virtual functions of a base class, that code will be independent of how many classes you derive from the base (but will have the power of calling newer derived versions of the virtual functions) and hence better the code maintainability.

- ankit.batra11 March 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this is correct! Even Learncpp.com also suggest the same reason. Just to rephrase it, we assign derived class objects to base class pointers so that we have a generic way of accessing all derived objects. But this limits the access to base class part of information in the derived class objects. In order to have base class pointers access derived class data access in the derived class objects assigned to it, we use virtual function!

- Saurabh November 13, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Dynamic binding

- nit March 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Basically the power of c++ is polymorphism.

One name and many forms. Run time polymorphism is acheieved by virtual functions only.
resolving which function to be called at runtime ie object creation.
and after all whole world is going dynamic leaving behind static.

- Amit March 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

To reuse the code of object, we need inheritance. By upcasting an object of the derived class to a pointer of the base class, that object can be used wherever the base class can be used. However, this object would still perform as one of the base class without polymorphism (i.e., virtual function). In order for the object of the derived class to behave as the derived class, we need to use "virtual function".

In summary, reuse of object code --> inheritance --> upcasting --> polymorphism (virtual function).

- Anonymous March 31, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More