# Create template-based files

CLion provides [file templates](using-file-and-code-templates.html) for most of the [supported languages](clion-features-in-different-languages.html). These templates help you create files with initial content already present.

There are four templates for C/C++: C++ Class, C++ Source File, C++ Header File, and C++ Module Interface Unit.

![File templates for C/C++](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newfile_cpptemplates.png)

> **Tip:**
> To edit file templates, call Edit File templates from the Project view context menu or go to `Settings | Editor | File and Code Templates`.

Procedure: Create a new C++ class

1. In the [Project tool window](project-tool-window.html), select the directory in which you want to add new files. Right-click it and select `New | C++ Class` from the context menu.

2. ![New C++ class dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_new_cpp_class_dialog.png)

* Specify the name of the new class.

* Use the default file type or choose from the drop-down list: ![New class file extensions](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newclass_filetype.png) Click the spanner icon to access the default file extensions settings: ![File extensions settings](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newfiles_typesettings.png)

* In the Namespace field, set the namespace for your class. If you specify a nonexistent namespace, it will be created along with the new class. > **Tip:** > To create an unnamed namespace, type a blank space. This field has basic validation checking for whether the identifier is a valid namespace name (or a blank space).

* Select the Create header only checkbox if you want to create the header file only.

* CLion can automatically add files to CMake targets. Select the target from the list or click Add new target to create a new one. For more information, refer to [Adding files to CMake projects](managing-cmake-project-files.html).

Procedure: Create a new C/C++ source file

1. In the [Project tool window](project-tool-window.html), select the directory in which you want to add new files. Right-click it and select `New | C/C++ Source File` from the context menu.

2. ![Adding a new source file](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newSourceFile.png)

* Specify the name of the new file.

* Use the default file type or choose from the drop-down list: ![New C++ file extensions](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newcppfile_extensions.png) Click the spanner icon to access the default file extensions settings: ![File extensions settings](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newfiles_typesettings.png)

* Select the Create an associated header checkbox to create the corresponding header file as well.

* CLion can automatically add files to CMake targets. Select the target from the list or click Add new target to create a new one. For more information, refer to [Adding files to CMake projects](managing-cmake-project-files.html).

Procedure: Create a new C/C++ header

1. In the [Project tool window](project-tool-window.html), select the directory in which you want to add new files. Right-click it and select `New | C/C++ Header File` from the context menu.

2. ![Adding a new header file](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newHeaderFile.png)

* Specify the name of the new file.

* Use the default file type or choose from the drop-down list: ![New C++ header extensions](https://resources.jetbrains.com/help/img/idea/2026.2/cl_newheader_fileextensions.png) Click the spanner icon to access the default file extensions settings: ![File extensions settings](https://resources.jetbrains.com/help/img/idea/2026.2/C++](code-style-c-c.html)

