faq5 - FREQUENTLY ASKED QUESTIONS Content Questions What is...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
FREQUENTLY ASKED QUESTIONS October 19, 2011 Content Questions What is a virtual method? You can think of a virtual method, or virtual function, as a kind of variable function, i.e. a function that acts like a variable. Classes can have mem- ber functions (“methods”), and an abstract base class might not have all its functions specified when the function is defined: this kind of abstract, undefined function is a “virtual function”. It needs to be defined in a derived (inherited) class, and only then can the abstract class be instantiated. I’ll go through some of these C++ concepts next class. Here’s an example from Wikipedia: “A base class Animal could have a virtual function eat . Subclass Fish would implement eat() differently than subclass Wolf , but you can invoke eat() on any class instance referred to as Animal , and get the eat() be- haviour of the specific subclass. This allows a programmer to process a list of objects of class Animal , telling each in turn to eat (by calling
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/16/2012 for the course PHYSICS 392 taught by Professor Scholberg during the Fall '11 term at Duke.

Page1 / 2

faq5 - FREQUENTLY ASKED QUESTIONS Content Questions What is...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online