Override functions
You can override any function of a parent class by generating necessary code from a predefined template. CLion creates a stub that contains a call to the function of the superclass, leaving the developer with the task of providing some meaningful source code in the method's body.
Override a member function of a superclass
On the Generate Alt+Insert, and select Override methods.
menu, click Control+O. Alternatively, you can right-click anywhere in the class file, then clickSelect the functions to override (hold the Shift or Ctrl key to perform a multi-selection). The list does not include the functions that are already overridden or cannot be accessed from the current subclass.
Click OK and provide the source code for the function body.
Change the function body
The code template used for overriding functions (Overridden method body) accepts predefined template variables from the File Header include template (such as ${USER}
, ${DATE}
, and so on).
For example, consider the following code template:
The template expands into the following code: