Adobe Interview Question for Computer Scientists


Team: Big Data
Country: United States
Interview Type: In-Person




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

A virtual function is a member function of a class that can be overridden at runtime in a derived class (dynamic rather than static binding). Calling the function via a base-class pointer will result in a call to the derived class version. The reference is resolved at runtime, using the virtual function table (vtable), which is just a table of function addresses. The base class function need not even be defined, it can be "pure virtual", meant to be defined only in derived classes. This of course makes the base class abstract so it cannot be instantiated, only used as a common ancestor for subclasses.

It's important to make base class destructors virtual, so that the in the event your derived-class object is deleted via a base-class pointer, the derived version of the destructor is called, because your derived class could allocate memory that needs freeing, register for events using a pointer to itself which needs unregistering, etc.

- Adam Smith November 01, 2014 | 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