CLion 2018.1 Help

Implementing Functions

If a class has a base class with pure virtual functions, it can't be instantiated unless it implements those functions. CLion creates stubs of the implemented functions, with the default return values for the primitive types, and null values for the objects.

To implement required functions:

  1. On the Code menu, click Implement methods (Ctrl+I). Alternatively, you can right-click anywhere in the class file, then click Generate (Alt+Insert), and select Implement methods.
  2. Select the methods to implement. If necessary, select the Copy JavaDoc check box to insert JavaDoc comments for the implemented interface or abstract class.
  3. Click OK.

Change function body

The code template used for implementing functions (Implemented function body) accepts predefined template variables from the File Header include template (such as, ${USER}, ${DATE}, etc.)

For example, consider the following file template:

#if ($DEFAULT_RETURN_VALUE == "result") $RETURN_TYPE result; return result;#elseif ($RETURN_TYPE != "void") return $DEFAULT_RETURN_VALUE;#end

This template expands into the following code:

int Calendar::getMonth() { return 0;/// TODO (wombat, 1/22/2015):To change the body of an implemented function, use File | Settings - Editor - File and Code Templates. } void Calendar::setMonth(int month) { /// TODO (wombat, 1/22/2015):To change the body of an implemented function, use File | Settings - Editor - File and Code Templates. }
Last modified: 30 May 2018