CLion 1.5 Help

Implementing Functions

In this section:

Overview

If a class is declared as implementing a certain interface or extending a class with abstract functions, it has to implement the functions of such interface or class. CLion creates stubs of the implemented functions, with the default return values for the primitive types, and null values for the objects.

Implementing functions

To implement function , follow these steps:

  1. Do one of the following:
    • On the main menu, choose Code | Implement function.
    • Press Ctrl+I
    • Right-click the editor, choose Generate on the context menu, or press Alt+Insert, and choose Implement functions.

    The Select functions to implement dialog appears, displaying the list of classes and interfaces with the functions that can be implemented.

  2. Select one or more functions to implement. For multiple selection, use Ctrl and Shift keys.
    cl_implement
  3. Click OK.

Changing function body

File template responsible for implementing a method (Implemented method body) accepts predefined template variables from "File Header" (File | Settings - Editor - File and Code Templates - Code - File Header ), e.g. ${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. }

See Also

Last modified: 2 February 2016