Partager via


// Overridables Comment

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at -- Overridables Comment.

The // Overridables section of an MFC class declaration contains virtual functions that you can override in a derived class when you need to modify the base class behavior. They are usually named starting with "On", although it is not strictly necessary. Functions here are designed to be overridden, and often implement or provide some sort of "callback" or "hook." Typically, these members are protected.

In MFC itself, pure virtual functions are always placed in this section. A pure virtual function in C++ is one of the form:

virtual void OnDraw( ) = 0;

In the sample listing from class CStdioFile, in An Example of the Comments, the list includes no overridables section. Class CDocument, on the other hand, lists approximately 10 overridable member functions.

In some classes, you may also see the comment // Advanced Overridables. These are functions that only advanced programmers should attempt to override. You will probably never need to override them.

Note

The conventions described in this article also work well, in general, for Automation (formerly known as OLE Automation) methods and properties. Automation methods are similar to MFC operations. Automation properties are similar to MFC attributes. Automation events (supported for ActiveX controls, formerly known as OLE controls) are similar to MFC overridable member functions.

See Also

Using the MFC Source Files
An Example of the Comments
// Implementation Comment
// Constructors Comment
// Attributes Comment
// Operations Comment