# 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.

Procedure: Override a member function of a superclass

1. On the `Code` menu, click `Override methods` `Ctrl+O` (Windows), `⌃ O` (macOS), `⌘ O` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ O` (macOS System Shortcuts), `Ctrl+O` (XWin), `Ctrl+O` (GNOME), `Ctrl+O` (KDE), `Ctrl+O` (Emacs), `Ctrl+O` (Sublime Text), `Ctrl+O` (Sublime Text (macOS)), `⌘ ⌃ O` (Xcode), `Ctrl+O` (Visual Studio), `Ctrl+O` (Visual Studio (macOS)), `Ctrl+O` (ReSharper), `Ctrl+O` (ReSharper (macOS)), `Ctrl+O` (QtCreator), `Ctrl+O` (QtCreator (macOS)), `Ctrl+O` (NetBeans), `Ctrl+O` (Eclipse), `Ctrl+O` (Eclipse (macOS)). Alternatively, you can right-click anywhere in the class file, then click Generate `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `⌘ N` (Xcode), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Alt+Insert` (ReSharper), `⌘ ⌃ N` (ReSharper (macOS)), `Alt+Insert` (QtCreator), `Alt+Insert` (QtCreator (macOS)), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)), and select Override methods.

2. Select 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.

![Selecting functions to override](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_codegen_override.png)

3. 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:

```CPLUSPLUS
#if ($CALL_SUPER != "")#if ($RETURN_TYPE != "void")return#end $CALL_SUPER;#end
// TODO ($USER, $DATE):To change the function body, use Settings - Editor - File and Code Templates.
```

The template expands into the following code:

```CPLUSPLUS
int Calendar::getYear() {
    return 0; // TODO (wombat, 1/22/2022):To change the function body, use Settings - Editor - File and Code Templates.
}
```

