Table of content

Add Forward Declaration

In C/C++, Visual Assist can add a forward declaration for a referenced symbol, e.g. a pointer to a class, to make an unknown symbol known. The forward declaration, if sufficient, typically reduces compile time relative to a comparable include directive.


Hover over, or move the text caret to, an unknown symbol and access the Quick Action and Refactoring menu. Choose "Add Forward Declaration".

The necessary forward declaration is inserted in a sensible location, e.g. after other forward declarations or after the first group of include directives.

The position of the text caret is unchanged.

Add Forward Declaration versus Add include Directive 

Visual Assist offers to add a forward declaration based only on a reference to a symbol. Visual Assist does not assess references to other symbols to determine if an include directive is more appropriate, or necessary. Hence, for every symbol that can be resolved by a forward declaration, Visual Assist also offers to resolve the symbol via an include directive.

Select the method more appropriate, or necessary, for the entire header.